Presence: Add another user to the list of contacts to notify of presence and other changes
(topic string, online, enabled bool)
| 44 | |
| 45 | // Presence: Add another user to the list of contacts to notify of presence and other changes |
| 46 | func (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 |
no test coverage detected