diff --git a/meshchat.py b/meshchat.py index cef37bd..4f2f71f 100644 --- a/meshchat.py +++ b/meshchat.py @@ -1514,6 +1514,12 @@ def convert_lxmf_state_to_string(self, lxmf_message: LXMF.LXMessage): # convert database announce to a dictionary def convert_db_announce_to_dict(self, announce: database.Announce): + + # get display name for lxmf delivery announce + display_name = None + if announce.aspect == "lxmf.delivery": + display_name = self.parse_lxmf_display_name(announce.app_data) + return { "id": announce.id, "destination_hash": announce.destination_hash, @@ -1521,6 +1527,7 @@ def convert_db_announce_to_dict(self, announce: database.Announce): "identity_hash": announce.identity_hash, "identity_public_key": announce.identity_public_key, "app_data": announce.app_data, + "display_name": display_name, "created_at": announce.created_at, "updated_at": announce.updated_at, } @@ -1855,15 +1862,20 @@ def get_lxmf_conversation_name(self, destination_hash): .get_or_none()) # if app data is available in database, it should be base64 encoded text that was announced - # we will return this as the conversation name + # we will return the parsed lxmf display name as the conversation name if lxmf_announce is not None and lxmf_announce.app_data is not None: - try: - app_data_bytes = base64.b64decode(lxmf_announce.app_data) - return LXMF.display_name_from_app_data(app_data_bytes) - except: - pass + return self.parse_lxmf_display_name(app_data_base64=lxmf_announce.app_data) + + # announce did not have app data, so provide a fallback name + return "Anonymous Peer" - return "Unknown" + # reads the lxmf display name from the provided base64 app data + def parse_lxmf_display_name(self, app_data_base64: str): + try: + app_data_bytes = base64.b64decode(app_data_base64) + return LXMF.display_name_from_app_data(app_data_bytes) + except: + return "Anonymous Peer" # returns true if the conversation has messages newer than the last read at timestamp def is_lxmf_conversation_unread(self, destination_hash): diff --git a/src/frontend/components/messages/ConversationViewer.vue b/src/frontend/components/messages/ConversationViewer.vue index d3aa3f3..8ffb179 100644 --- a/src/frontend/components/messages/ConversationViewer.vue +++ b/src/frontend/components/messages/ConversationViewer.vue @@ -8,7 +8,7 @@