fix: Show original poster name in room messages, not room server name

Room servers forward messages with the original author's 4-byte public
key prefix (roomPostAuthorPrefix). Was ignoring this — all room messages
showed the room server's name as sender.

Now resolves the actual poster's name from roomPostAuthorPrefix by
matching against the contacts list. Falls back to room server name if
the author isn't a known contact.

Also fixes findContactByPrefix to accept 4-byte prefixes (was rejecting
anything shorter than 6 bytes).

Fixes #22
This commit is contained in:
Janez T
2026-03-19 09:20:22 +01:00
parent f286b0afd1
commit e683ab933f
3 changed files with 27 additions and 11 deletions

View File

@@ -1195,10 +1195,11 @@ class ContactsProvider with ChangeNotifier {
/// Find contact by public key prefix (6 bytes)
Contact? _findContactByPrefix(Uint8List prefix) {
if (prefix.length < 6) return null;
if (prefix.isEmpty) return null;
final takeLen = prefix.length < 6 ? prefix.length : 6;
final prefixHex = prefix
.sublist(0, 6)
.sublist(0, takeLen)
.map((b) => b.toRadixString(16).padLeft(2, '0'))
.join('');