mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
streams: Send different peer events for web & non-web public streams.
Earlier, we used to send a single event for all web-public and public streams. But public streams can have guests, which means the peer user ids for each of them can be different based on which guests are subscribed to which channel. In the previous code, we were using the last stream id from another loop to get subscribers, which was causing a lot of non-deterministic failures in our test, since that stream id could keep on changing. Moreover, it doesn't make much sense to use that id here. This commit still keeps around the optimisation for public channels with non-guest users. It will send one event for all public channels with non-guest users, one for web public channels and for the rest of the channels it will send an event for each channel with a different set of peer user ids.
This commit is contained in:
committed by
Tim Abbott
parent
bdd11577bf
commit
1014de23a8
@@ -1834,20 +1834,21 @@ class NormalActionsTest(BaseAction):
|
||||
realm.signup_announcements_stream = get_stream("core team", realm)
|
||||
realm.save(update_fields=["signup_announcements_stream"])
|
||||
|
||||
with self.verify_action(num_events=5) as events:
|
||||
with self.verify_action(num_events=6) as events:
|
||||
self.register("test1@zulip.com", "test1")
|
||||
self.assert_length(events, 5)
|
||||
self.assert_length(events, 6)
|
||||
|
||||
check_realm_user_add("events[0]", events[0])
|
||||
new_user_profile = get_user_by_delivery_email("test1@zulip.com", self.user_profile.realm)
|
||||
self.assertEqual(new_user_profile.delivery_email, "test1@zulip.com")
|
||||
|
||||
check_subscription_peer_add("events[3]", events[3])
|
||||
check_subscription_peer_add("events[4]", events[4])
|
||||
|
||||
check_message("events[4]", events[4])
|
||||
check_message("events[5]", events[5])
|
||||
self.assertIn(
|
||||
f'data-user-id="{new_user_profile.id}">test1_zulip.com</span> joined this organization.',
|
||||
events[4]["message"]["content"],
|
||||
events[5]["message"]["content"],
|
||||
)
|
||||
|
||||
check_user_group_add_members("events[1]", events[1])
|
||||
@@ -1865,19 +1866,20 @@ class NormalActionsTest(BaseAction):
|
||||
realm.signup_announcements_stream = get_stream("core team", realm)
|
||||
realm.save(update_fields=["signup_announcements_stream"])
|
||||
|
||||
with self.verify_action(num_events=5) as events:
|
||||
with self.verify_action(num_events=6) as events:
|
||||
self.register("test1@zulip.com", "test1")
|
||||
self.assert_length(events, 5)
|
||||
self.assert_length(events, 6)
|
||||
check_realm_user_add("events[0]", events[0])
|
||||
new_user_profile = get_user_by_delivery_email("test1@zulip.com", self.user_profile.realm)
|
||||
self.assertEqual(new_user_profile.email, f"user{new_user_profile.id}@zulip.testserver")
|
||||
|
||||
check_subscription_peer_add("events[3]", events[3])
|
||||
check_subscription_peer_add("events[4]", events[4])
|
||||
|
||||
check_message("events[4]", events[4])
|
||||
check_message("events[5]", events[5])
|
||||
self.assertIn(
|
||||
f'data-user-id="{new_user_profile.id}">test1_zulip.com</span> joined this organization',
|
||||
events[4]["message"]["content"],
|
||||
events[5]["message"]["content"],
|
||||
)
|
||||
|
||||
check_user_group_add_members("events[1]", events[1])
|
||||
@@ -3479,6 +3481,7 @@ class NormalActionsTest(BaseAction):
|
||||
name="hamletcharacters", realm=self.user_profile.realm
|
||||
)
|
||||
hamlet = self.example_user("hamlet")
|
||||
self.user_profile = hamlet
|
||||
setting_group = self.create_or_update_anonymous_group_for_setting(
|
||||
[user_profile, hamlet], [members_group]
|
||||
)
|
||||
@@ -3575,16 +3578,17 @@ class NormalActionsTest(BaseAction):
|
||||
self.make_stream("Test new stream")
|
||||
self.subscribe(user_profile, "Test new stream")
|
||||
self.subscribe(self.user_profile, "Test new stream")
|
||||
with self.verify_action(num_events=6) as events:
|
||||
with self.verify_action(num_events=7) as events:
|
||||
do_deactivate_user(user_profile, acting_user=None)
|
||||
check_subscription_peer_remove("events[0]", events[0])
|
||||
check_user_group_remove_members("events[1]", events[1])
|
||||
check_subscription_peer_remove("events[1]", events[1])
|
||||
check_user_group_remove_members("events[2]", events[2])
|
||||
check_user_group_remove_members("events[3]", events[3])
|
||||
check_user_group_update("events[4]", events[4], {"can_mention_group"})
|
||||
check_realm_user_remove("events[5]]", events[5])
|
||||
check_user_group_remove_members("events[4]", events[4])
|
||||
check_user_group_update("events[5]", events[5], {"can_mention_group"})
|
||||
check_realm_user_remove("events[6]]", events[6])
|
||||
self.assertEqual(
|
||||
events[4]["data"]["can_mention_group"],
|
||||
events[5]["data"]["can_mention_group"],
|
||||
UserGroupMembersDict(direct_members=[], direct_subgroups=[members_group.id]),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user