storage: Add a add_thread method:

This method is used to add a thread on an existing History record.

rel 457
This commit is contained in:
Goffi 2025-05-06 00:34:01 +02:00
commit 7642c7b1db

View file

@ -731,6 +731,34 @@ class Storage:
f"Can't store message, unexpected exception (uid: {data['uid']}): {e}"
)
@aio
async def add_thread(
self,
message_uid: str,
thread_id: str,
parent_id: str|None,
is_retroactive: bool,
) -> None:
"""Add a thread to a message.
@param message_uid: Internal ID of the message (History.uid) to which the thread
is added.
@param thread_id: The thread ID to set.
@param parent_id: The parent message ID in the thread.
@param is_retroactive: Whether the thread ID was added after the message was sent.
Is is used when we want to relate a parent message to a new thread, when the
parent message didn't have a thread ID initially.
"""
async with self.session() as session:
thread = Thread(
thread_id=thread_id,
parent_id=parent_id,
is_retroactive=is_retroactive,
history_uid=message_uid,
)
session.add(thread)
await session.commit()
## Private values
def _get_private_class(self, binary, profile):