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

Function sendPush

server/push.go:188–230  ·  view source on GitHub ↗

Process push notification.

(rcpt *push.Receipt)

Source from the content-addressed store, hash-verified

186
187// Process push notification.
188func sendPush(rcpt *push.Receipt) {
189 if rcpt == nil || globals.usersUpdate == nil {
190 return
191 }
192
193 var local *UserCacheReq
194
195 // In case of a cluster pushes will be initiated at the nodes which own the users.
196 // Sort users into local and remote.
197 if globals.cluster != nil {
198 local = &UserCacheReq{PushRcpt: &push.Receipt{
199 Payload: rcpt.Payload,
200 Channel: rcpt.Channel,
201 To: make(map[types.Uid]push.Recipient),
202 }}
203 remote := &UserCacheReq{PushRcpt: &push.Receipt{
204 Payload: rcpt.Payload,
205 Channel: rcpt.Channel,
206 To: make(map[types.Uid]push.Recipient),
207 }}
208
209 for uid, recipient := range rcpt.To {
210 if globals.cluster.isRemoteTopic(uid.UserId()) {
211 remote.PushRcpt.To[uid] = recipient
212 } else {
213 local.PushRcpt.To[uid] = recipient
214 }
215 }
216
217 if len(remote.PushRcpt.To) > 0 || remote.PushRcpt.Channel != "" {
218 globals.cluster.routeUserReq(remote)
219 }
220 } else {
221 local = &UserCacheReq{PushRcpt: rcpt}
222 }
223
224 if len(local.PushRcpt.To) > 0 || local.PushRcpt.Channel != "" {
225 select {
226 case globals.usersUpdate <- local:
227 default:
228 }
229 }
230}

Callers 5

topicUnregMethod · 0.85
handleNoteBroadcastMethod · 0.85
anotherUserSubMethod · 0.85

Calls 3

isRemoteTopicMethod · 0.80
UserIdMethod · 0.80
routeUserReqMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…