mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-11 08:03:09 -06:00
Undo changes to filterSharedUsers
This commit is contained in:
parent
25b147faba
commit
f62e99e6f3
|
|
@ -94,7 +94,8 @@ func DeviceListCatchup(
|
||||||
queryRes.UserIDs = append(queryRes.UserIDs, joinUserIDs...)
|
queryRes.UserIDs = append(queryRes.UserIDs, joinUserIDs...)
|
||||||
queryRes.UserIDs = append(queryRes.UserIDs, leaveUserIDs...)
|
queryRes.UserIDs = append(queryRes.UserIDs, leaveUserIDs...)
|
||||||
queryRes.UserIDs = util.UniqueStrings(queryRes.UserIDs)
|
queryRes.UserIDs = util.UniqueStrings(queryRes.UserIDs)
|
||||||
sharedUsersMap := filterSharedUsers(ctx, db, userID, queryRes.UserIDs)
|
var sharedUsersMap map[string]int
|
||||||
|
sharedUsersMap, queryRes.UserIDs = filterSharedUsers(ctx, db, userID, queryRes.UserIDs)
|
||||||
userSet := make(map[string]bool)
|
userSet := make(map[string]bool)
|
||||||
for _, userID := range res.DeviceLists.Changed {
|
for _, userID := range res.DeviceLists.Changed {
|
||||||
if sharedUsersMap[userID] > 0 {
|
if sharedUsersMap[userID] > 0 {
|
||||||
|
|
@ -225,16 +226,15 @@ func TrackChangedUsers(
|
||||||
// it down to include only users who the requesting user shares a room with.
|
// it down to include only users who the requesting user shares a room with.
|
||||||
func filterSharedUsers(
|
func filterSharedUsers(
|
||||||
ctx context.Context, db storage.SharedUsers, userID string, usersWithChangedKeys []string,
|
ctx context.Context, db storage.SharedUsers, userID string, usersWithChangedKeys []string,
|
||||||
) map[string]int {
|
) (map[string]int, []string) {
|
||||||
sharedUsersMap := make(map[string]int, len(usersWithChangedKeys))
|
sharedUsersMap := make(map[string]int, len(usersWithChangedKeys))
|
||||||
for _, userID := range usersWithChangedKeys {
|
for _, userID := range usersWithChangedKeys {
|
||||||
sharedUsersMap[userID] = 0
|
sharedUsersMap[userID] = 0
|
||||||
}
|
}
|
||||||
sharedUsers, err := db.SharedUsers(ctx, userID, usersWithChangedKeys)
|
sharedUsers, err := db.SharedUsers(ctx, userID, usersWithChangedKeys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.GetLogger(ctx).WithError(err).Errorf("db.SharedUsers failed: %s", err)
|
|
||||||
// default to all users so we do needless queries rather than miss some important device update
|
// default to all users so we do needless queries rather than miss some important device update
|
||||||
return nil
|
return nil, usersWithChangedKeys
|
||||||
}
|
}
|
||||||
for _, userID := range sharedUsers {
|
for _, userID := range sharedUsers {
|
||||||
sharedUsersMap[userID]++
|
sharedUsersMap[userID]++
|
||||||
|
|
@ -243,7 +243,7 @@ func filterSharedUsers(
|
||||||
// and if we are in 0 rooms then we don't technically share any room with ourselves so we wouldn't
|
// and if we are in 0 rooms then we don't technically share any room with ourselves so we wouldn't
|
||||||
// be notified about key changes.
|
// be notified about key changes.
|
||||||
sharedUsersMap[userID] = 1
|
sharedUsersMap[userID] = 1
|
||||||
return sharedUsersMap
|
return sharedUsersMap, sharedUsers
|
||||||
}
|
}
|
||||||
|
|
||||||
func joinedRooms(res *types.Response, userID string) []string {
|
func joinedRooms(res *types.Response, userID string) []string {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue