From 522c4ed56b2568d203740d4f900ee4e88cb843d3 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 30 Jan 2026 07:29:39 -0600 Subject: [PATCH] Update Meshtastic/Helpers/TAK/CoTMessage.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Meshtastic/Helpers/TAK/CoTMessage.swift | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Meshtastic/Helpers/TAK/CoTMessage.swift b/Meshtastic/Helpers/TAK/CoTMessage.swift index 1d8419b8..12aff014 100644 --- a/Meshtastic/Helpers/TAK/CoTMessage.swift +++ b/Meshtastic/Helpers/TAK/CoTMessage.swift @@ -319,9 +319,26 @@ struct CoTMessage: Identifiable, Sendable { // Chat elements (for b-t-f messages) if let chat { - let messageId = UUID().uuidString - let senderUid = uid.hasPrefix("GeoChat.") ? String(uid.split(separator: ".")[1]) : uid + // Derive sender UID and messageId from GeoChat UID when possible, with safe fallbacks + let senderUid: String + let messageId: String + if uid.hasPrefix("GeoChat.") { + let components = uid.split(separator: ".") + if components.count >= 3 { + // Expected GeoChat format: GeoChat.. + senderUid = String(components[1]) + messageId = String(components[2]) + } else { + // Malformed GeoChat UID; fall back safely + senderUid = uid + messageId = uid + } + } else { + // Non-GeoChat UID; use uid as both sender and stable message identifier + senderUid = uid + messageId = uid + } cot += "<__chat parent='RootContactGroup' groupOwner='false' " cot += "messageId='\(messageId)' " cot += "chatroom='\(chat.chatroom.xmlEscaped)' id='\(chat.chatroom.xmlEscaped)' "