From 9ad28d60a4bb21aaad0e1f50299e8bc429e5fa1f Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 24 Nov 2025 12:50:17 +1300 Subject: [PATCH] show incoming caller name if possible --- meshchat.py | 31 +++++++++++++++++-- src/frontend/components/App.vue | 22 +++++-------- .../components/telephone/TelephonePage.vue | 15 +++++++-- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/meshchat.py b/meshchat.py index 89f6c98..34f4db6 100644 --- a/meshchat.py +++ b/meshchat.py @@ -360,9 +360,11 @@ class ReticulumMeshChat: # get remote identity hash remote_identity_hash = None + remote_identity_name = None remote_identity = telephone_active_call.get_remote_identity() if remote_identity is not None: remote_identity_hash = remote_identity.hash.hex() + remote_identity_name = self.get_name_for_identity_hash(remote_identity_hash) active_call = { "hash": telephone_active_call.hash.hex(), @@ -370,6 +372,7 @@ class ReticulumMeshChat: "is_incoming": telephone_active_call.is_incoming, "is_outgoing": telephone_active_call.is_outgoing, "remote_identity_hash": remote_identity_hash, + "remote_identity_name": remote_identity_name, } return web.json_response({ @@ -3338,6 +3341,30 @@ class ReticulumMeshChat: "announce": self.convert_db_announce_to_dict(announce), }))) + # try and get a name for the provided identity hash + def get_name_for_identity_hash(self, identity_hash: str): + + # recall identity + identity = RNS.Identity.recall(bytes.fromhex(identity_hash), from_identity_hash=True) + if identity is None: + return None + + # get lxmf.delivery destination hash + lxmf_destination_hash = RNS.Destination.hash(identity, "lxmf", "delivery").hex() + + # use custom name if available + custom_name = self.get_custom_destination_display_name(lxmf_destination_hash) + if custom_name is not None: + return custom_name + + # use lxmf name if available + lxmf_name = self.get_lxmf_conversation_name(lxmf_destination_hash, default_name=None) + if lxmf_name is not None: + return lxmf_name + + # couldn't find a name for this identity + return None + # gets the custom display name a user has set for the provided destination hash def get_custom_destination_display_name(self, destination_hash: str): @@ -3351,7 +3378,7 @@ class ReticulumMeshChat: # get name to show for an lxmf conversation # currently, this will use the app data from the most recent announce # TODO: we should fetch this from our contacts database, when it gets implemented, and if not found, fallback to app data - def get_lxmf_conversation_name(self, destination_hash): + def get_lxmf_conversation_name(self, destination_hash, default_name:str|None="Anonymous Peer"): # get lxmf.delivery announce from database for the provided destination hash lxmf_announce = (database.Announce.select() @@ -3365,7 +3392,7 @@ class ReticulumMeshChat: 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 default_name # reads the lxmf display name from the provided base64 app data def parse_lxmf_display_name(self, app_data_base64: str, default_value: str | None = "Anonymous Peer"): diff --git a/src/frontend/components/App.vue b/src/frontend/components/App.vue index 4290cf9..d003e02 100644 --- a/src/frontend/components/App.vue +++ b/src/frontend/components/App.vue @@ -264,24 +264,18 @@ dark:bg-zinc-800 dark:text-white dark:hover:bg-zinc-700 dark:focus-visible:outli
- Incoming Call - Outgoing Call + Active Call + Incoming Call {{ activeCall.status }} + Outgoing Call {{ activeCall.status }} + Status {{ activeCall.status }} Status
- - Connecting... - Active - - {{ Utils.formatDestinationHash(activeCall.remote_identity_hash) }} - Ringing... - - - - Connecting... - Active - Calling... + + {{ activeCall.remote_identity_name }} + {{ Utils.formatDestinationHash(activeCall.remote_identity_hash) }} + Unknown Caller
Hung up, waiting for call...
diff --git a/src/frontend/components/telephone/TelephonePage.vue b/src/frontend/components/telephone/TelephonePage.vue index f6dca5a..a38d1c3 100644 --- a/src/frontend/components/telephone/TelephonePage.vue +++ b/src/frontend/components/telephone/TelephonePage.vue @@ -71,7 +71,11 @@
-
{{ activeCall.remote_identity_hash || "Unknown" }}
+
+ {{ activeCall.remote_identity_name }} + {{ Utils.formatDestinationHash(activeCall.remote_identity_hash) }} + Unknown +
Busy... @@ -80,7 +84,7 @@ Available... Ringing... Connecting... - Established... + Connected Status: {{ activeCall.status }}
@@ -113,8 +117,15 @@