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

get_users_who_share_room_with_user(...) should use the users_who_share_private_rooms/users_in_public_rooms tables instead of calculating it themselves again (get_users_in_room mis-use) #13967

Open
@MadLittleMods

Description

@MadLittleMods

get_users_who_share_room_with_user(...) should use the users_who_share_private_rooms/users_in_public_rooms tables instead of calculating it themselves again.

This might be a nice optimization for the presence and device list sharing code where get_users_who_share_room_with_user is used.

async def get_users_who_share_room_with_user(self, user_id: str) -> Set[str]:
"""Returns the set of users who share a room with `user_id`"""
room_ids = await self.get_rooms_for_user(user_id)
user_who_share_room = set()
for room_id in room_ids:
user_ids = await self.get_users_in_room(room_id)
user_who_share_room.update(user_ids)
return user_who_share_room


Discovered while working on #13958 and seeing code for users sharing rooms in #13966

See #13575 (comment) for the original exploration around finding get_users_in_room mis-uses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-PerformancePerformance, both client-facing and admin-facingT-EnhancementNew features, changes in functionality, improvements in performance, or user-facing enhancements.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions