messages: Support passing user ID for stream operator.

ok_to_include_history fuction was updated to expect stream ID.

Fixes part of #9474.
This commit is contained in:
Priyank Patel
2019-08-07 15:32:19 +00:00
committed by Tim Abbott
parent 5eab5bbc3e
commit 3680393b47
3 changed files with 69 additions and 20 deletions

View File

@@ -186,6 +186,13 @@ def can_access_stream_history_by_name(user_profile: UserProfile, stream_name: st
return False
return can_access_stream_history(user_profile, stream)
def can_access_stream_history_by_id(user_profile: UserProfile, stream_id: int) -> bool:
try:
stream = get_stream_by_id_in_realm(stream_id, user_profile.realm)
except Stream.DoesNotExist:
return False
return can_access_stream_history(user_profile, stream)
def filter_stream_authorization(user_profile: UserProfile,
streams: Iterable[Stream]) -> Tuple[List[Stream], List[Stream]]:
streams_subscribed = set() # type: Set[int]