mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
Extract StreamTopicTarget.get_active_subscriptions().
Note that this code leads to a slightly different query, because we join to one row in the small Recipient table to match stream_id to recipient.type_id.
This commit is contained in:
@@ -830,10 +830,7 @@ def get_recipient_info(recipient, sender_id, stream_topic, possibly_mentioned_us
|
||||
assert(len(message_to_user_ids) in [1, 2])
|
||||
|
||||
elif recipient.type == Recipient.STREAM:
|
||||
subscription_rows = Subscription.objects.filter(
|
||||
recipient=recipient,
|
||||
active=True,
|
||||
).values(
|
||||
subscription_rows = stream_topic.get_active_subscriptions().values(
|
||||
'user_profile_id',
|
||||
'push_notifications',
|
||||
'in_home_view',
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
from typing import (Dict, List, Text, Set)
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from zerver.models import MutedTopic
|
||||
from zerver.lib.stream_subscription import (
|
||||
get_active_subscriptions_for_stream_id,
|
||||
)
|
||||
|
||||
from zerver.models import (
|
||||
MutedTopic,
|
||||
)
|
||||
|
||||
class StreamTopicTarget(object):
|
||||
'''
|
||||
@@ -26,3 +33,7 @@ class StreamTopicTarget(object):
|
||||
row['user_profile_id']
|
||||
for row in query
|
||||
}
|
||||
|
||||
def get_active_subscriptions(self):
|
||||
# type: () -> QuerySet
|
||||
return get_active_subscriptions_for_stream_id(self.stream_id)
|
||||
|
||||
Reference in New Issue
Block a user