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)
| 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. |
| 122 | func (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. |
| 146 | func pushForChanDelete(topicName string, now time.Time) *push.Receipt { |
no test coverage detected