diff --git a/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt b/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt index 1b120b9b..74302cb9 100644 --- a/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt +++ b/app/src/main/java/com/bitchat/android/ui/ChatViewModel.kt @@ -266,9 +266,21 @@ class ChatViewModel( // Check for commands if (content.startsWith("/")) { + val selectedLocationForCommand = state.selectedLocationChannel.value commandProcessor.processCommand(content, meshService, meshService.myPeerID, { messageContent, mentions, channel -> - meshService.sendMessage(messageContent, mentions, channel) - }, this) + if (selectedLocationForCommand is com.bitchat.android.geohash.ChannelID.Location) { + // Route command-generated public messages via Nostr in geohash channels + nostrGeohashService.sendGeohashMessage( + messageContent, + selectedLocationForCommand.channel, + meshService.myPeerID, + state.getNicknameValue() + ) + } else { + // Default: route via mesh + meshService.sendMessage(messageContent, mentions, channel) + } + }) return } diff --git a/app/src/main/java/com/bitchat/android/ui/CommandProcessor.kt b/app/src/main/java/com/bitchat/android/ui/CommandProcessor.kt index 4e426454..d36f67b4 100644 --- a/app/src/main/java/com/bitchat/android/ui/CommandProcessor.kt +++ b/app/src/main/java/com/bitchat/android/ui/CommandProcessor.kt @@ -291,7 +291,11 @@ class CommandProcessor( if (parts.size > 1) { val targetName = parts[1].removePrefix("@") val actionMessage = "* ${state.getNicknameValue() ?: "someone"} $verb $targetName $object_ *" - + + // If we're in a geohash location channel, don't add a local echo here. + // NostrGeohashService.sendGeohashMessage() will add the local echo with proper metadata. + val isInLocationChannel = state.selectedLocationChannel.value is com.bitchat.android.geohash.ChannelID.Location + // Send as regular message if (state.getSelectedPrivateChatPeerValue() != null) { val peerID = state.getSelectedPrivateChatPeerValue()!! @@ -304,6 +308,9 @@ class CommandProcessor( ) { content, peerIdParam, recipientNicknameParam, messageId -> sendPrivateMessageVia(meshService, content, peerIdParam, recipientNicknameParam, messageId) } + } else if (isInLocationChannel) { + // Let the transport layer add the echo; just send it out + onSendMessage(actionMessage, emptyList(), null) } else { val message = BitchatMessage( sender = state.getNicknameValue() ?: myPeerID,