mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-08-04 15:03:00 +10:00
Improve sender name resolution for room server messages by handling missing room-contact keys
This commit is contained in:
committed by
just-stuff-tm
parent
4c7ee3b3b0
commit
f5154b0033
@@ -3506,7 +3506,9 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
// For 1:1 chats, sender is implicit (null)
|
// For 1:1 chats, sender is implicit (null)
|
||||||
String? senderName;
|
String? senderName;
|
||||||
if (isRoomServer && !msg.isOutgoing) {
|
if (isRoomServer && !msg.isOutgoing) {
|
||||||
// Resolve sender from the message's fourByteRoomContactKey
|
// 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<Contact?>().firstWhere(
|
final senderContact = _contacts.cast<Contact?>().firstWhere(
|
||||||
(c) =>
|
(c) =>
|
||||||
c != null &&
|
c != null &&
|
||||||
@@ -3514,6 +3516,7 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
orElse: () => null,
|
orElse: () => null,
|
||||||
);
|
);
|
||||||
senderName = senderContact?.name;
|
senderName = senderContact?.name;
|
||||||
|
}
|
||||||
} else if (isRoomServer && msg.isOutgoing) {
|
} else if (isRoomServer && msg.isOutgoing) {
|
||||||
senderName = selfName;
|
senderName = selfName;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user