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

Method pushForReadRcpt

server/push.go:163–185  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

161
162// Prepares payload to be delivered to a mobile device as a push notification in response to receiving "read" notification.
163func (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.
188func sendPush(rcpt *push.Receipt) {

Callers 1

handleNoteBroadcastMethod · 0.95

Calls 1

UserIdMethod · 0.80

Tested by

no test coverage detected