mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
events: Fix applying stream creation events in apply_event.
There was a bug in apply_event code where only a stream which is not private is added to the "never_subscribed" data after a stream creation event. Instead, it should be added to the "never_subscribed" data irrespective of permission policy of the stream as we already send stream creation events only to those users who can access the stream. Due to the current bug, private streams were not being added to "never_subscribed" data in apply_event for admins as well. This commit fixes it and also makes sure the "never_subscribed" list is sorted which was not done before and was also a bug. The bugs mentioned above were unnoticed as the tests did not cover these cases and this commit also adds tests for those cases.
This commit is contained in:
committed by
Alex Vandiver
parent
c90fd388c8
commit
9636362cbd
@@ -1347,12 +1347,16 @@ Output:
|
||||
return stream.id
|
||||
|
||||
# Subscribe to a stream directly
|
||||
def subscribe(self, user_profile: UserProfile, stream_name: str) -> Stream:
|
||||
def subscribe(
|
||||
self, user_profile: UserProfile, stream_name: str, invite_only: 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)
|
||||
stream, from_stream_creation = create_stream_if_needed(
|
||||
realm, stream_name, invite_only=invite_only
|
||||
)
|
||||
bulk_add_subscriptions(realm, [stream], [user_profile], acting_user=None)
|
||||
return stream
|
||||
|
||||
|
||||
Reference in New Issue
Block a user