Send stream_id in subscription updates.

This commit is contained in:
Steve Howell
2017-03-04 16:30:48 -08:00
committed by Tim Abbott
parent 0f02031846
commit 0bb1af0fd9
3 changed files with 9 additions and 7 deletions

View File

@@ -1833,12 +1833,12 @@ def log_subscription_property_change(user_email, stream_name, property, value):
'value': value}
log_event(event)
def do_change_subscription_property(user_profile, sub, stream_name,
def do_change_subscription_property(user_profile, sub, stream,
property_name, value):
# type: (UserProfile, Subscription, Text, Text, Any) -> None
# type: (UserProfile, Subscription, Stream, Text, Any) -> None
setattr(sub, property_name, value)
sub.save(update_fields=[property_name])
log_subscription_property_change(user_profile.email, stream_name,
log_subscription_property_change(user_profile.email, stream.name,
property_name, value)
event = dict(type="subscription",
@@ -1846,7 +1846,8 @@ def do_change_subscription_property(user_profile, sub, stream_name,
email=user_profile.email,
property=property_name,
value=value,
name=stream_name)
stream_id=stream.id,
name=stream.name)
send_event(event, [user_profile.id])
def do_activate_user(user_profile, log=True, join_date=timezone.now()):

View File

@@ -660,10 +660,11 @@ class EventsRegisterTest(ZulipTestCase):
('type', equals('subscription')),
('op', equals('update')),
('property', equals('pin_to_top')),
('stream_id', check_int),
('value', check_bool),
])
stream = "Denmark"
sub = get_subscription(stream, self.user_profile)
stream = get_stream("Denmark", self.user_profile.realm)
sub = get_subscription(stream.name, self.user_profile)
do_change_subscription_property(self.user_profile, sub, stream, "pin_to_top", False)
for pinned in (True, False):
events = self.do_test(lambda: do_change_subscription_property(self.user_profile, sub, stream, "pin_to_top", pinned))

View File

@@ -427,7 +427,7 @@ def json_subscription_property(request, user_profile, subscription_data=REQ(
if property_conversion:
return json_error(property_conversion)
do_change_subscription_property(user_profile, sub, stream_name,
do_change_subscription_property(user_profile, sub, stream,
property, value)
response_data.append({'stream': stream_name,