MCPcopy
hub / github.com/tinode/chat / addToPerSubs

Method addToPerSubs

server/pres.go:46–64  ·  view source on GitHub ↗

Presence: Add another user to the list of contacts to notify of presence and other changes

(topic string, online, enabled bool)

Source from the content-addressed store, hash-verified

44
45// Presence: Add another user to the list of contacts to notify of presence and other changes
46func (t *Topic) addToPerSubs(topic string, online, enabled bool) {
47 if topic == t.name {
48 // No need to push updates to self
49 return
50 }
51
52 // TODO: maybe skip loading channel subscriptions. They can's send or receive these notifications anyway.
53
54 if uid1, uid2, err := types.ParseP2P(topic); err == nil {
55 // If this is a P2P topic, index it by second user's ID
56 if uid1.UserId() == t.name {
57 topic = uid2.UserId()
58 } else {
59 topic = uid1.UserId()
60 }
61 }
62
63 t.perSubs[topic] = perSubsData{online: online, enabled: enabled}
64}
65
66// loadContacts loads topic.perSubs to support presence notifications.
67// perSubs contains (a) topics that the user wants to notify of his presence and

Callers 2

loadContactsMethod · 0.95
procPresReqMethod · 0.95

Calls 2

ParseP2PFunction · 0.92
UserIdMethod · 0.80

Tested by

no test coverage detected