Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Always ensure we return a value for every user in get_rooms_for_users
Browse files Browse the repository at this point in the history
The cached list (sensibly) requires that every input value has a
corresponding output.
  • Loading branch information
Fizzadar committed Sep 28, 2022
1 parent bd70af9 commit 7b0e311
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions synapse/storage/databases/main/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from collections import defaultdict
from typing import (
TYPE_CHECKING,
Collection,
Expand Down Expand Up @@ -696,7 +695,8 @@ async def get_rooms_for_users(
desc="get_rooms_for_users",
)

user_rooms: Dict[str, Set[str]] = defaultdict(set)
user_rooms: Dict[str, Set[str]] = {user_id: set() for user_id in user_ids}

for row in rows:
user_rooms[row["state_key"]].add(row["room_id"])

Expand Down

0 comments on commit 7b0e311

Please sign in to comment.