direct_messages: Use DM groups for 1:1 or self DMs if present.

This is a preparatory refactor for migrating the internal structure of
Recipient objects for group DMs to use the DirectMessageGroup type,
not the legacy PERSONAL type. This step has the message-sending code
path check if a DirectMessageGroupe exists and prefer it if available.

It should have no effect in production other than doing a useless
database query for each outgoing DM, since we do not at present ever
create such DirectMessageGroup objects. (It will not add a marginal
database query once the migration is complete, just during this
transition).
This commit is contained in:
Mohammad Reza Kianifar
2025-05-15 03:02:11 +00:00
committed by Tim Abbott
parent e5db9614eb
commit a0488715f3
10 changed files with 151 additions and 28 deletions

View File

@@ -1176,7 +1176,7 @@ Output:
read_by_sender: bool = True,
) -> int:
to_user_ids = [u.id for u in to_users]
assert len(to_user_ids) >= 2
assert len(to_user_ids) >= 1
(sending_client, _) = Client.objects.get_or_create(name="test suite")