Skip to content

Commit

Permalink
fix for breakage in online status due to background subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Dec 1, 2019
1 parent 1932ae7 commit 2af3410
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions server/topic.go
Expand Up @@ -234,7 +234,7 @@ func (t *Topic) run(hub *Hub) {
} else if pssd := t.remSession(leave.sess, asUid); pssd != nil {
// Just leaving the topic without unsubscribing if user is subscribed.

pud := t.perUser[asUid]
pud := t.perUser[pssd.uid]
if pssd.ref == nil {
pud.online--
}
Expand Down Expand Up @@ -267,7 +267,7 @@ func (t *Topic) run(hub *Hub) {
}
}

t.perUser[asUid] = pud
t.perUser[pssd.uid] = pud

if leave.id != "" {
leave.sess.queueOut(NoErr(leave.id, t.original(asUid), now))
Expand Down Expand Up @@ -1201,6 +1201,7 @@ func (t *Topic) requestSub(h *Hub, sess *Session, asUid types.Uid, asLvl auth.Le
userData.online++
t.perUser[asUid] = userData
}

return changed, nil
}

Expand Down Expand Up @@ -2719,7 +2720,7 @@ func (t *Topic) addSession(s *Session, asUid types.Uid) bool {
// Removes session record if 'asUid' matches subscribed user.
func (t *Topic) remSession(s *Session, asUid types.Uid) *perSessionData {
pssd := t.sessions[s]
if pssd.uid == asUid {
if pssd.uid == asUid || asUid.IsZero() {
// Check for deferred presence notification and cancel it if found.
if pssd.ref != nil {
t.defrNotif.Remove(pssd.ref)
Expand Down
4 changes: 2 additions & 2 deletions server/user.go
Expand Up @@ -658,8 +658,8 @@ func usersRegisterTopic(t *Topic, add bool) {
return
}

if len(t.perUser) == 0 {
// me and fnd topics
if t.cat == types.TopicCatFnd || t.cat == types.TopicCatMe {
// Ignoring me and fnd topics.
return
}

Expand Down

0 comments on commit 2af3410

Please sign in to comment.