Skip to content

Commit

Permalink
fix for tinode/webapp/#21
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Oct 13, 2018
1 parent 432d72d commit 0b7bff9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/topic.go
Expand Up @@ -2187,7 +2187,9 @@ func (t *Topic) evictUser(uid types.Uid, unsub bool, skip string) {

// Prepares a payload to be delivered to a mobile device as a push notification.
func (t *Topic) makePushReceipt(fromUid types.Uid, data *MsgServerData) *pushReceipt {
// Index user_id -> location_of_user_in_Rcpt_To_field
idx := make(map[types.Uid]int, t.subsCount())
// Initialize the push receipt.
receipt := push.Receipt{
To: make([]push.Recipient, t.subsCount()),
Payload: push.Payload{
Expand All @@ -2199,8 +2201,11 @@ func (t *Topic) makePushReceipt(fromUid types.Uid, data *MsgServerData) *pushRec

i := 0
for uid := range t.perUser {
if (t.perUser[uid].modeWant & t.perUser[uid].modeGiven).IsPresencer() && !t.perUser[uid].deleted {
// Only send to those users who have notifications enabled
// Done't send to the originating user, send only to those who have notifications enabled.
if uid != fromUid &&
(t.perUser[uid].modeWant & t.perUser[uid].modeGiven).IsPresencer() &&
!t.perUser[uid].deleted {

receipt.To[i].User = uid
idx[uid] = i
i++
Expand Down

0 comments on commit 0b7bff9

Please sign in to comment.