mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 05:42:46 +00:00
Don't create fictitious presence entries (#2381)
* Don't create fictitious presence entries for users that don't have any * Update whitelist, since that test probably shouldn't be passing * Fix panics
This commit is contained in:
parent
6c5c6d73d7
commit
66b397b3c6
6 changed files with 33 additions and 19 deletions
|
@ -16,7 +16,6 @@ package streams
|
|||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"sync"
|
||||
|
||||
|
@ -80,11 +79,10 @@ func (p *PresenceStreamProvider) IncrementalSync(
|
|||
if _, ok := presences[roomUsers[i]]; ok {
|
||||
continue
|
||||
}
|
||||
// Bear in mind that this might return nil, but at least populating
|
||||
// a nil means that there's a map entry so we won't repeat this call.
|
||||
presences[roomUsers[i]], err = p.DB.GetPresence(ctx, roomUsers[i])
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
continue
|
||||
}
|
||||
req.Log.WithError(err).Error("unable to query presence for user")
|
||||
return from
|
||||
}
|
||||
|
@ -93,8 +91,10 @@ func (p *PresenceStreamProvider) IncrementalSync(
|
|||
}
|
||||
|
||||
lastPos := to
|
||||
for i := range presences {
|
||||
presence := presences[i]
|
||||
for _, presence := range presences {
|
||||
if presence == nil {
|
||||
continue
|
||||
}
|
||||
// Ignore users we don't share a room with
|
||||
if req.Device.UserID != presence.UserID && !p.notifier.IsSharedUser(req.Device.UserID, presence.UserID) {
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue