Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
reaction: Use the generic 'event_recipient_ids_for_action_on_messages'.
Prakhar Pratyush5c23a3f186c8
diff --git a/zerver/actions/reactions.py b/zerver/actions/reactions.pyindex 8f18c6305ce..b1f72d2053a 100644--- a/zerver/actions/reactions.py+++ b/zerver/actions/reactions.py@@ -5,15 +5,15 @@ from zerver.lib.emoji import check_emoji_request, get_emoji_datafrom zerver.lib.exceptions import ReactionExistsErrorfrom zerver.lib.message import (access_message_and_usermessage,+ event_recipient_ids_for_action_on_messages,set_visibility_policy_possible,should_change_visibility_policy,visibility_policy_for_participation,)from zerver.lib.message_cache import update_message_cache-from zerver.lib.stream_subscription import subscriber_ids_with_stream_history_accessfrom zerver.lib.streams import access_stream_by_idfrom zerver.lib.user_message import create_historical_user_messages-from zerver.models import Message, Reaction, Recipient, Stream, UserMessage, UserProfile+from zerver.models import Message, Reaction, UserProfilefrom zerver.tornado.django_api import send_event_on_commit@@ -43,28 +43,7 @@ def notify_reaction_update(# Update the cached message since new reaction is added.update_message_cache([message])- # Recipients for message update events, including reactions, are- # everyone who got the original message, plus subscribers of- # streams with the access to stream's full history.- #- # This means reactions won't live-update in preview narrows for a- # stream the user isn't yet subscribed to; this is the right- # performance tradeoff to avoid sending every reaction to public- # stream messages to all users.- #- # To ensure that reactions do live-update for any user who has- # actually participated in reacting to a message, we add a- # "historical" UserMessage row for any user who reacts to message,- # subscribing them to future notifications, even if they are not- # subscribed to the stream.- user_ids = set(- UserMessage.objects.filter(message=message.id).values_list("user_profile_id", flat=True)- )- if message.recipient.type == Recipient.STREAM:- stream_id = message.recipient.type_id- stream = Stream.objects.get(id=stream_id)- user_ids |= subscriber_ids_with_stream_history_access(stream)-+ user_ids = event_recipient_ids_for_action_on_messages([message])send_event_on_commit(user_profile.realm, event, list(user_ids))