mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 19:31:58 +00:00
Use stream_id as key for subscription removals.
Have the server send down the stream's id for removal events, and have the client use that id to look up the stream in its internal data structures. This sets the stage for eventually just sending the stream id (and not the stream name) down to clients, once all our clients are ready to use the stream id. (imported from commit 922516c98fb79ffad8ae7da0396646663ca54fd0)
This commit is contained in:
@@ -99,8 +99,9 @@ function get_events_success(events) {
|
||||
subs.mark_subscribed(sub.name, sub);
|
||||
});
|
||||
} else if (event.op === 'remove') {
|
||||
_.each(event.subscriptions, function (sub) {
|
||||
subs.mark_unsubscribed(sub.name);
|
||||
_.each(event.subscriptions, function (rec) {
|
||||
var sub = stream_data.get_sub_by_id(rec.stream_id);
|
||||
subs.mark_sub_unsubscribed(sub);
|
||||
});
|
||||
} else if (event.op === 'update') {
|
||||
subs.update_subscription_properties(event.name, event.property, event.value);
|
||||
|
||||
@@ -1054,7 +1054,7 @@ def notify_subscriptions_removed(user_profile, streams, no_log=False):
|
||||
'names': [stream.name for stream in streams],
|
||||
'domain': stream.realm.domain})
|
||||
|
||||
payload = [dict(name=stream.name) for stream in streams]
|
||||
payload = [dict(name=stream.name, stream_id=stream.id) for stream in streams]
|
||||
event = dict(type="subscription", op="remove",
|
||||
subscriptions=payload)
|
||||
send_event(event, [user_profile.id])
|
||||
|
||||
@@ -295,6 +295,7 @@ class EventsRegisterTest(AuthedTestCase):
|
||||
('subscriptions', check_list(
|
||||
check_dict([
|
||||
('name', equals('test_stream')),
|
||||
('stream_id', check_int),
|
||||
]),
|
||||
)),
|
||||
])
|
||||
|
||||
@@ -231,7 +231,7 @@ class StreamAdminTest(AuthedTestCase):
|
||||
self.assertEqual(deletion_event, dict(
|
||||
op='remove',
|
||||
type='subscription',
|
||||
subscriptions=[{'name': active_name}]
|
||||
subscriptions=[{'name': active_name, 'stream_id': stream.id}]
|
||||
))
|
||||
else:
|
||||
# You could delete the stream, but you weren't on it so you don't
|
||||
|
||||
Reference in New Issue
Block a user