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

Method pushForGroupSub

server/push.go:122–143  ·  view source on GitHub ↗

Prepares payload to be delivered to a mobile device as a push notification in response to a new subscription in a group topic.

(fromUid types.Uid, now time.Time)

Source from the content-addressed store, hash-verified

120
121// Prepares payload to be delivered to a mobile device as a push notification in response to a new subscription in a group topic.
122func (t *Topic) pushForGroupSub(fromUid types.Uid, now time.Time) *push.Receipt {
123 receipt := t.preparePushForSubReceipt(fromUid, now)
124 if pud, ok := t.perUser[fromUid]; ok {
125 receipt.Payload.ModeWant = pud.modeWant
126 receipt.Payload.ModeGiven = pud.modeGiven
127 } else {
128 // Sender is not a subscriber (BUG?)
129 return nil
130 }
131
132 for uid, pud := range t.perUser {
133 // Send only to those who have notifications enabled.
134 mode := pud.modeWant & pud.modeGiven
135 if mode.IsPresencer() && mode.IsReader() && !pud.deleted && !pud.isChan {
136 receipt.To[uid] = push.Recipient{}
137 }
138 }
139 if len(receipt.To) > 0 || receipt.Channel != "" {
140 return receipt
141 }
142 return nil
143}
144
145// Prepares payload to be delivered to a mobile device as a push notification in response to owner deleting a channel.
146func pushForChanDelete(topicName string, now time.Time) *push.Receipt {

Callers 1

Calls 3

IsPresencerMethod · 0.80
IsReaderMethod · 0.80

Tested by

no test coverage detected