mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 23:43:43 +00:00
events: Fix races in stream creation event and add tests.
This fixes 2 issues: * Being added to an invite_only stream did not correctly update the "streams" key of the initial state. * Once that's resolved, subscribe_to_stream when called on a nonexistant stream would both send a "create" event (from create_stream_if_needed) and an "occupy" event (from bulk_add_subscriptions). The second event should just be suppressed in that case, and this implements that suppression.
This commit is contained in:
@@ -417,10 +417,11 @@ class ZulipTestCase(TestCase):
|
||||
realm = get_realm_by_email_domain(email)
|
||||
try:
|
||||
stream = get_stream(stream_name, realm)
|
||||
from_creation = False
|
||||
except Stream.DoesNotExist:
|
||||
stream, _ = create_stream_if_needed(realm, stream_name)
|
||||
stream, from_creation = create_stream_if_needed(realm, stream_name)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
bulk_add_subscriptions([stream], [user_profile])
|
||||
bulk_add_subscriptions([stream], [user_profile], from_creation=from_creation)
|
||||
return stream
|
||||
|
||||
def unsubscribe_from_stream(self, email, stream_name):
|
||||
|
||||
Reference in New Issue
Block a user