diff --git a/syncapi/internal/keychange.go b/syncapi/internal/keychange.go index 8553537e1..531e299a0 100644 --- a/syncapi/internal/keychange.go +++ b/syncapi/internal/keychange.go @@ -94,7 +94,8 @@ func DeviceListCatchup( queryRes.UserIDs = append(queryRes.UserIDs, joinUserIDs...) queryRes.UserIDs = append(queryRes.UserIDs, leaveUserIDs...) 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) for _, userID := range res.DeviceLists.Changed { if sharedUsersMap[userID] > 0 { @@ -225,16 +226,15 @@ func TrackChangedUsers( // it down to include only users who the requesting user shares a room with. func filterSharedUsers( ctx context.Context, db storage.SharedUsers, userID string, usersWithChangedKeys []string, -) map[string]int { +) (map[string]int, []string) { sharedUsersMap := make(map[string]int, len(usersWithChangedKeys)) for _, userID := range usersWithChangedKeys { sharedUsersMap[userID] = 0 } sharedUsers, err := db.SharedUsers(ctx, userID, usersWithChangedKeys) 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 - return nil + return nil, usersWithChangedKeys } for _, userID := range sharedUsers { 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 // be notified about key changes. sharedUsersMap[userID] = 1 - return sharedUsersMap + return sharedUsersMap, sharedUsers } func joinedRooms(res *types.Response, userID string) []string {