mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
models: Remove get_huddle_recipient and use get_or_create_huddle.
This commit removes get_huddle_recipient function and we now use get_or_create_huddle in get_recipient_from_user_profiles. As a result of this change, we do not fetch the recipient from Huddle object but instead get it using the "id" and "recipient_id" fields available from Huddle object like we do for a personal message. This change allows us to not fetch recipient object using select_related when querying the Huddle object.
This commit is contained in:
@@ -56,7 +56,7 @@ from zerver.models import (
|
||||
UserMessage,
|
||||
UserProfile,
|
||||
flush_per_request_caches,
|
||||
get_huddle_recipient,
|
||||
get_or_create_huddle,
|
||||
get_realm,
|
||||
get_stream,
|
||||
get_system_bot,
|
||||
@@ -660,16 +660,14 @@ class MessagePOSTTest(ZulipTestCase):
|
||||
|
||||
msg = self.get_last_message()
|
||||
self.assertEqual("Test message", msg.content)
|
||||
self.assertEqual(
|
||||
msg.recipient_id,
|
||||
get_huddle_recipient(
|
||||
{
|
||||
self.example_user("hamlet").id,
|
||||
self.example_user("othello").id,
|
||||
self.example_user("cordelia").id,
|
||||
}
|
||||
).id,
|
||||
huddle = get_or_create_huddle(
|
||||
[
|
||||
self.example_user("hamlet").id,
|
||||
self.example_user("othello").id,
|
||||
self.example_user("cordelia").id,
|
||||
]
|
||||
)
|
||||
self.assertEqual(msg.recipient_id, huddle.recipient_id)
|
||||
|
||||
def test_personal_message_copying_self(self) -> None:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user