mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
fix(companion): show room-server messages on device, attributed to sender
Incoming room-server posts fired the notification and reached the app via the offline queue, but never appeared when the room was opened directly on the device: the on-device history (addDMMsg) was gated to ADV_TYPE_CHAT only, while rooms (ADV_TYPE_ROOM) share that same history list (keyed by the server's pubkey). Include ADV_TYPE_ROOM so room posts are stored too. A room carries many guests, so prefix each stored post with its author — resolved from the signed message's sender pubkey prefix (fallback: short hex) — and have the DM history view split "Sender: text" for room contacts so each line is attributed to the guest who wrote it, instead of showing the room server's name for every message. Builds verified: WioTrackerL1 + GAT562 30S solo. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -485,8 +485,29 @@ void MyMesh::queueMessage(const ContactInfo &from, uint8_t txt_type, mesh::Packe
|
||||
if (should_display && _ui) {
|
||||
_ui->newMsg(path_len, from.name, text, offline_queue_len, from.type, from.id.pub_key);
|
||||
_ui->notify(UIEventType::contactMessage);
|
||||
if (from.type == ADV_TYPE_CHAT)
|
||||
// Add to the on-device conversation history. Room servers (ADV_TYPE_ROOM) are
|
||||
// viewed through the same history list as chat contacts (keyed by the server's
|
||||
// pubkey), so their posts must be stored too — otherwise an incoming room
|
||||
// message fires the notification and reaches the app via the offline queue but
|
||||
// never shows when the room is opened directly on the device.
|
||||
if (from.type == ADV_TYPE_CHAT) {
|
||||
_ui->addDMMsg(from.id.pub_key, false, text, sender_timestamp);
|
||||
} else if (from.type == ADV_TYPE_ROOM) {
|
||||
// A room carries many guests, so prefix the post with its author so the UI
|
||||
// can attribute each line. The signed message's `extra` holds the sender's
|
||||
// pubkey prefix; resolve it to a contact name, falling back to a short hex.
|
||||
char labeled[MAX_TEXT_LEN + 40]; // room text + "Sender: " (history store truncates)
|
||||
if (extra && extra_len >= 4) {
|
||||
ContactInfo* sc = lookupContactByPubKey(extra, extra_len);
|
||||
if (sc && sc->name[0])
|
||||
snprintf(labeled, sizeof(labeled), "%s: %s", sc->name, text);
|
||||
else
|
||||
snprintf(labeled, sizeof(labeled), "%02X%02X: %s", extra[0], extra[1], text);
|
||||
} else {
|
||||
snprintf(labeled, sizeof(labeled), "%s", text);
|
||||
}
|
||||
_ui->addDMMsg(from.id.pub_key, false, labeled, sender_timestamp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user