MCPcopy Index your code
hub / github.com/tinode/chat / preparePushForSubReceipt

Method preparePushForSubReceipt

server/push.go:87–108  ·  view source on GitHub ↗
(fromUid types.Uid, now time.Time)

Source from the content-addressed store, hash-verified

85}
86
87func (t *Topic) preparePushForSubReceipt(fromUid types.Uid, now time.Time) *push.Receipt {
88 // The `Topic` in the push receipt is `t.xoriginal` for group topics, `fromUid` for p2p topics,
89 // not the t.original(fromUid) because it's the topic name as seen by the recipient, not by the sender.
90 topic := t.xoriginal
91 if t.cat == types.TopicCatP2P {
92 topic = fromUid.UserId()
93 }
94
95 // Initialize the push receipt.
96 receipt := &push.Receipt{
97 To: make(map[types.Uid]push.Recipient, t.subsCount()),
98 Payload: push.Payload{
99 What: push.ActSub,
100 Silent: false,
101 Topic: topic,
102 From: fromUid.UserId(),
103 Timestamp: now,
104 SeqId: t.lastID,
105 },
106 }
107 return receipt
108}
109
110// Prepares payload to be delivered to a mobile device as a push notification in response to a new subscription in a p2p topic.
111func (t *Topic) pushForP2PSub(fromUid, toUid types.Uid, want, given types.AccessMode, now time.Time) *push.Receipt {

Callers 2

pushForP2PSubMethod · 0.95
pushForGroupSubMethod · 0.95

Calls 2

subsCountMethod · 0.95
UserIdMethod · 0.80

Tested by

no test coverage detected