From f5154b003368bec7b35d12267505625456277782 Mon Sep 17 00:00:00 2001 From: just_stuff_tm <133525672+just-stuff-tm@users.noreply.github.com> Date: Mon, 2 Mar 2026 19:33:09 -0500 Subject: [PATCH] Improve sender name resolution for room server messages by handling missing room-contact keys --- lib/connector/meshcore_connector.dart | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index a5898499..3f69d0a8 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -3506,14 +3506,17 @@ class MeshCoreConnector extends ChangeNotifier { // For 1:1 chats, sender is implicit (null) String? senderName; if (isRoomServer && !msg.isOutgoing) { - // Resolve sender from the message's fourByteRoomContactKey - final senderContact = _contacts.cast().firstWhere( - (c) => - c != null && - _matchesPrefix(c.publicKey, msg.fourByteRoomContactKey), - orElse: () => null, - ); - senderName = senderContact?.name; + // Treat a missing room-contact key as unknown instead of matching every + // contact via an empty prefix. + if (msg.fourByteRoomContactKey.length == 4) { + final senderContact = _contacts.cast().firstWhere( + (c) => + c != null && + _matchesPrefix(c.publicKey, msg.fourByteRoomContactKey), + orElse: () => null, + ); + senderName = senderContact?.name; + } } else if (isRoomServer && msg.isOutgoing) { senderName = selfName; }