Skip to content

Commit

Permalink
Always use stored last viewed at if present
Browse files Browse the repository at this point in the history
This partially reverts commit 3a0d0b3. We can't trust that Mattermost
has updated the last viewed for channel which is why we store the
LastViewedAt internally (see PR#361 and #245).
  • Loading branch information
hloeung committed Apr 8, 2021
1 parent d047782 commit 83659db
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mm-go-irckit/userbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,13 +591,13 @@ func (u *User) addUserToChannelWorker(channels <-chan *bridge.ChannelInfo, throt
if since == 0 {
continue
}
// We used to stored last viewed at if present.

// We use the stored LastViewedAt if present as we can't
// always trust that the Mattermost server has updated the
// last viewed at for the channel (PR#361).
u.lastViewedAtMutex.RLock()
if lastViewedAt, ok := u.lastViewedAt[brchannel.ID]; ok {
// But only use the stored last viewed if it's later than what the server knows.
if lastViewedAt > since {
since = lastViewedAt + 1
}
since = lastViewedAt + 1
}
u.lastViewedAtMutex.RUnlock()
// post everything to the channel you haven't seen yet
Expand Down

0 comments on commit 83659db

Please sign in to comment.