mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-10-25 18:40:12 -04:00
fix for conversations marked as unread when we are first to send a message
This commit is contained in:
parent
00dec8cc44
commit
6f081eb90e
1 changed files with 5 additions and 5 deletions
10
meshchat.py
10
meshchat.py
|
|
@ -1852,15 +1852,11 @@ class ReticulumMeshChat:
|
|||
# returns true if the conversation has messages newer than the last read at timestamp
|
||||
def is_lxmf_conversation_unread(self, destination_hash):
|
||||
|
||||
# get lxmf.delivery announce from database for the provided destination hash
|
||||
# get lxmf conversation read state from database for the provided destination hash
|
||||
lxmf_conversation_read_state = (database.LxmfConversationReadState.select()
|
||||
.where(database.LxmfConversationReadState.destination_hash == destination_hash)
|
||||
.get_or_none())
|
||||
|
||||
# user has never read this conversation, so it's unread
|
||||
if lxmf_conversation_read_state is None:
|
||||
return True
|
||||
|
||||
# get most recent incoming message from destination hash
|
||||
latest_incoming_lxmf_message = (database.LxmfMessage.select()
|
||||
.where(database.LxmfMessage.source_hash == destination_hash)
|
||||
|
|
@ -1871,6 +1867,10 @@ class ReticulumMeshChat:
|
|||
if latest_incoming_lxmf_message is None:
|
||||
return False
|
||||
|
||||
# user has never read this conversation, so it's unread
|
||||
if lxmf_conversation_read_state is None:
|
||||
return True
|
||||
|
||||
# conversation is unread if last read at is before the latest incoming message creation date
|
||||
conversation_last_read_at = datetime.strptime(lxmf_conversation_read_state.last_read_at, "%Y-%m-%d %H:%M:%S.%f%z")
|
||||
conversation_latest_message_at = datetime.strptime(latest_incoming_lxmf_message.created_at, "%Y-%m-%d %H:%M:%S.%f%z")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue