fix(avatar): acknowledge BOXIM messages as read
This commit is contained in:
@@ -268,6 +268,7 @@ class TakeoverService:
|
||||
messages.sort(key=lambda item: (_numeric_id(item.get("id")), item.get("sendTime") or 0))
|
||||
priming = not bool(cursor.initialized)
|
||||
max_message_id = _numeric_id(cursor.last_message_id)
|
||||
read_receipts: dict[str, int] = {}
|
||||
for message in messages:
|
||||
self._record_message(
|
||||
db,
|
||||
@@ -276,7 +277,19 @@ class TakeoverService:
|
||||
message,
|
||||
schedule_reply=not priming,
|
||||
)
|
||||
max_message_id = max(max_message_id, _numeric_id(message.get("id")))
|
||||
message_id = _numeric_id(message.get("id"))
|
||||
max_message_id = max(max_message_id, message_id)
|
||||
send_id = str(message.get("sendId") or "")
|
||||
recv_id = str(message.get("recvId") or "")
|
||||
if recv_id == cursor.boxim_owner_id and send_id and message_id:
|
||||
read_receipts[send_id] = max(read_receipts.get(send_id, 0), message_id)
|
||||
|
||||
# BOXIM publishes this HTTP state change to connected socket clients.
|
||||
# Do it before advancing the cursor so a failed receipt is retried.
|
||||
for peer_id, message_id in read_receipts.items():
|
||||
await self.boxim.mark_private_messages_read(
|
||||
session["access_token"], peer_id, message_id
|
||||
)
|
||||
|
||||
cursor.last_message_id = str(max_message_id)
|
||||
cursor.initialized = True
|
||||
|
||||
Reference in New Issue
Block a user