subs: Fix clearing unread counts when leaving private streams.

Because we use access_stream_by_id here, and that checks for an active
subscription to interact with a private stream, this didn't work.

The correct fix to add an option to active_stream_by_id to accept an
argument indicating whether we need an active subscription; for this
use case, we definitely do not.
This commit is contained in:
Tim Abbott
2017-11-29 14:35:33 -08:00
parent 5279ac4601
commit b2cb443d24
3 changed files with 22 additions and 7 deletions

View File

@@ -517,5 +517,9 @@ class DeferredWorker(QueueProcessingWorker):
user_profile = get_user_profile_by_id(event['user_profile_id'])
for stream_id in event['stream_ids']:
(stream, recipient, sub) = access_stream_by_id(user_profile, stream_id)
# Since the user just unsubscribed, we don't require
# an active Subscription object (otherwise, private
# streams would never be accessible)
(stream, recipient, sub) = access_stream_by_id(user_profile, stream_id,
require_active=False)
do_mark_stream_messages_as_read(user_profile, stream)