users: Update presence and user status code to support restricted users.

The presence and user status update events are only sent to accessible
users, i.e. guests do not receive presence and user status updates for
users they cannot access.
This commit is contained in:
Sahil Batra
2023-10-17 16:26:39 +05:30
committed by Tim Abbott
parent 650e55fef8
commit dbcc9ea826
13 changed files with 236 additions and 55 deletions

View File

@@ -591,7 +591,8 @@ def check_can_access_user(
def get_user_ids_who_can_access_user(target_user: UserProfile) -> List[int]:
# We assume that caller only needs active users here, since
# this function is used to get users to send events.
# this function is used to get users to send events and to
# send presence update.
realm = target_user.realm
if not user_access_restricted_in_realm(target_user):
return active_user_ids(realm.id)