Process push notification.
(rcpt *push.Receipt)
| 186 | |
| 187 | // Process push notification. |
| 188 | func 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 | } |
no test coverage detected
searching dependent graphs…