Prepares payload to be delivered to a mobile device as a push notification in response to receiving "read" notification.
(uid types.Uid, seq int, now time.Time)
| 161 | |
| 162 | // Prepares payload to be delivered to a mobile device as a push notification in response to receiving "read" notification. |
| 163 | func (t *Topic) pushForReadRcpt(uid types.Uid, seq int, now time.Time) *push.Receipt { |
| 164 | // The `Topic` in the push receipt is `t.xoriginal` for group topics, `fromUid` for p2p topics, |
| 165 | // not the t.original(fromUid) because it's the topic name as seen by the recipient, not by the sender. |
| 166 | topic := t.xoriginal |
| 167 | if t.cat == types.TopicCatP2P { |
| 168 | topic = uid.UserId() |
| 169 | } |
| 170 | |
| 171 | // Initialize the push receipt. |
| 172 | receipt := &push.Receipt{ |
| 173 | To: make(map[types.Uid]push.Recipient, 1), |
| 174 | Payload: push.Payload{ |
| 175 | What: push.ActRead, |
| 176 | Silent: true, |
| 177 | Topic: topic, |
| 178 | From: uid.UserId(), |
| 179 | Timestamp: now, |
| 180 | SeqId: seq, |
| 181 | }, |
| 182 | } |
| 183 | receipt.To[uid] = push.Recipient{} |
| 184 | return receipt |
| 185 | } |
| 186 | |
| 187 | // Process push notification. |
| 188 | func sendPush(rcpt *push.Receipt) { |
no test coverage detected