message_send: Add 'internal_prep_huddle_message' function.

This is a prep commit to extract out the logic to
create message from 'internal_send_huddle_message'
into a separate function 'internal_prep_huddle_message'.

We will use this new function to get the huddle message
without sending it immediately.
This commit is contained in:
Prakhar Pratyush 2024-02-26 20:51:09 +05:30 committed by Tim Abbott
parent 23fc04577b
commit 336d46001c
1 changed files with 16 additions and 4 deletions

View File

@ -1974,17 +1974,29 @@ def internal_send_stream_message_by_name(
return sent_message_result.message_id
def internal_send_huddle_message(
realm: Realm, sender: UserProfile, emails: List[str], content: str
) -> Optional[int]:
def internal_prep_huddle_message(
realm: Realm,
sender: UserProfile,
content: str,
emails: List[str],
) -> Optional[SendMessageRequest]:
addressee = Addressee.for_private(emails, realm)
message = _internal_prep_message(
return _internal_prep_message(
realm=realm,
sender=sender,
addressee=addressee,
content=content,
)
def internal_send_huddle_message(
realm: Realm, sender: UserProfile, emails: List[str], content: str
) -> Optional[int]:
message = internal_prep_huddle_message(realm, sender, content, emails)
if message is None:
return None
sent_message_result = do_send_messages([message])[0]
return sent_message_result.message_id