message send: Calculate presence_idle_user_ids after building user data.

This is a direct code move and a prep change for having this function look
at all the user data variables, not just `private_message` and `mentioned`.
This commit is contained in:
Abhijeet Prasad Bodas
2021-06-15 17:11:08 +05:30
committed by Tim Abbott
parent 42e4fa7952
commit b6806fbf9d

View File

@@ -1932,23 +1932,6 @@ def do_send_messages(
wide_message_dict = MessageDict.wide_dict(send_request.message, realm_id) wide_message_dict = MessageDict.wide_dict(send_request.message, realm_id)
user_flags = user_message_flags.get(send_request.message.id, {}) user_flags = user_message_flags.get(send_request.message.id, {})
sender = send_request.message.sender
message_type = wide_message_dict["type"]
presence_idle_user_ids = get_active_presence_idle_user_ids(
realm=sender.realm,
sender_id=sender.id,
message_type=message_type,
active_user_ids=send_request.active_user_ids,
user_flags=user_flags,
)
event = dict(
type="message",
message=send_request.message.id,
message_dict=wide_message_dict,
presence_idle_user_ids=presence_idle_user_ids,
)
""" """
TODO: We may want to limit user_ids to only those users who have TODO: We may want to limit user_ids to only those users who have
@@ -1994,6 +1977,24 @@ def do_send_messages(
users = [asdict(user_data_object) for user_data_object in user_data_objects] users = [asdict(user_data_object) for user_data_object in user_data_objects]
sender = send_request.message.sender
message_type = wide_message_dict["type"]
presence_idle_user_ids = get_active_presence_idle_user_ids(
realm=sender.realm,
sender_id=sender.id,
message_type=message_type,
active_user_ids=send_request.active_user_ids,
user_flags=user_flags,
)
event = dict(
type="message",
message=send_request.message.id,
message_dict=wide_message_dict,
presence_idle_user_ids=presence_idle_user_ids,
)
if send_request.message.is_stream_message(): if send_request.message.is_stream_message():
# Note: This is where authorization for single-stream # Note: This is where authorization for single-stream
# get_updates happens! We only attach stream data to the # get_updates happens! We only attach stream data to the