streams: Fix sending stream-related events to guests.

Previous behavior-
- Guest did not receive stream creation events for new
web-public streams.
- Guest did not receive peer_add and peer_remove events
for web-public and subscribed public streams.

This commit fixes the behavior to be -
- Guests now receive stream creation events for new
web-public streams.
- Guest now receive peer_add and peer_remove events for
web-public and subscribed public streams.
This commit is contained in:
Sahil Batra
2023-10-26 21:44:01 +05:30
committed by Tim Abbott
parent 71b8f49614
commit 9a6cf82adc
11 changed files with 161 additions and 63 deletions

View File

@@ -1389,14 +1389,18 @@ Output:
# Subscribe to a stream directly
def subscribe(
self, user_profile: UserProfile, stream_name: str, invite_only: bool = False
self,
user_profile: UserProfile,
stream_name: str,
invite_only: bool = False,
is_web_public: bool = False,
) -> Stream:
realm = user_profile.realm
try:
stream = get_stream(stream_name, user_profile.realm)
except Stream.DoesNotExist:
stream, from_stream_creation = create_stream_if_needed(
realm, stream_name, invite_only=invite_only
realm, stream_name, invite_only=invite_only, is_web_public=is_web_public
)
bulk_add_subscriptions(realm, [stream], [user_profile], acting_user=None)
return stream