diff --git a/bitchat/Nostr/NostrProtocol.swift b/bitchat/Nostr/NostrProtocol.swift index 4919b183..7ca4300a 100644 --- a/bitchat/Nostr/NostrProtocol.swift +++ b/bitchat/Nostr/NostrProtocol.swift @@ -107,7 +107,7 @@ struct NostrProtocol { teleported: Bool = false ) throws -> NostrEvent { var tags = [["g", geohash]] - if let nickname = nickname, !nickname.isEmpty { + if let nickname = nickname?.trimmingCharacters(in: .whitespacesAndNewlines), !nickname.isEmpty { tags.append(["n", nickname]) } if teleported { diff --git a/bitchat/ViewModels/ChatViewModel.swift b/bitchat/ViewModels/ChatViewModel.swift index 41dac351..05872bfc 100644 --- a/bitchat/ViewModels/ChatViewModel.swift +++ b/bitchat/ViewModels/ChatViewModel.swift @@ -897,7 +897,7 @@ final class ChatViewModel: ObservableObject, BitchatDelegate { if Date().timeIntervalSince(eventTime) < 15 { return } } if let nickTag = event.tags.first(where: { $0.first == "n" }), nickTag.count >= 2 { - let nick = nickTag[1] + let nick = nickTag[1].trimmingCharacters(in: .whitespacesAndNewlines) self.geoNicknames[event.pubkey.lowercased()] = nick } // Store mapping for geohash sender IDs used in messages (ensures consistent colors) @@ -1616,7 +1616,7 @@ final class ChatViewModel: ObservableObject, BitchatDelegate { } // Cache nickname from tag if present if let nickTag = event.tags.first(where: { $0.first == "n" }), nickTag.count >= 2 { - let nick = nickTag[1] + let nick = nickTag[1].trimmingCharacters(in: .whitespacesAndNewlines) self.geoNicknames[event.pubkey.lowercased()] = nick } // If this pubkey is blocked, skip mapping, participants, and timeline