fix(desktop): wire gift wrap broadcast for DM reactions
The sendWrappedReaction function was creating NIP-17 gift wraps via NIP17Factory but never broadcasting them. Added sendGiftWraps() to IAccount interface with implementations in both Desktop and Android. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1578,6 +1578,13 @@ class Account(
|
||||
broadcastPrivately(events)
|
||||
}
|
||||
|
||||
override suspend fun sendGiftWraps(wraps: List<GiftWrapEvent>) {
|
||||
wraps.forEach { wrap ->
|
||||
val relayList = computeRelayListToBroadcast(wrap)
|
||||
client.send(wrap, relayList)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun broadcastPrivately(signedEvents: NIP17Factory.Result) {
|
||||
val mine = signedEvents.wraps.filter { (it.recipientPubKey() == signer.pubKey) }
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.vitorpamplona.quartz.nip47WalletConnect.LnZapPaymentResponseEvent
|
||||
import com.vitorpamplona.quartz.nip47WalletConnect.Request
|
||||
import com.vitorpamplona.quartz.nip47WalletConnect.Response
|
||||
import com.vitorpamplona.quartz.nip57Zaps.IPrivateZapsDecryptionCache
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.utils.DualCase
|
||||
|
||||
/**
|
||||
@@ -106,4 +107,7 @@ interface IAccount {
|
||||
|
||||
/** Send a NIP-17 gift-wrapped direct message */
|
||||
suspend fun sendNip17PrivateMessage(template: EventTemplate<ChatMessageEvent>)
|
||||
|
||||
/** Broadcast pre-created gift wraps (e.g. reactions within group DMs) */
|
||||
suspend fun sendGiftWraps(wraps: List<GiftWrapEvent>)
|
||||
}
|
||||
|
||||
+21
@@ -39,6 +39,7 @@ import com.vitorpamplona.quartz.nip47WalletConnect.Request
|
||||
import com.vitorpamplona.quartz.nip47WalletConnect.Response
|
||||
import com.vitorpamplona.quartz.nip57Zaps.IPrivateZapsDecryptionCache
|
||||
import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.utils.DualCase
|
||||
|
||||
/**
|
||||
@@ -140,4 +141,24 @@ class DesktopIAccount(
|
||||
relayManager.send(wrap, targetRelays)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun sendGiftWraps(wraps: List<GiftWrapEvent>) {
|
||||
wraps.forEach { wrap ->
|
||||
val recipientKey = wrap.recipientPubKey()
|
||||
val targetRelays =
|
||||
if (recipientKey != null) {
|
||||
val dmRelays =
|
||||
localCache
|
||||
.getOrCreateUser(recipientKey)
|
||||
.dmInboxRelays()
|
||||
?.toSet()
|
||||
dmRelays?.ifEmpty { null }
|
||||
?: relayManager.connectedRelays.value
|
||||
} else {
|
||||
relayManager.connectedRelays.value
|
||||
}
|
||||
|
||||
relayManager.send(wrap, targetRelays)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-5
@@ -383,11 +383,7 @@ private suspend fun sendWrappedReaction(
|
||||
signer = account.signer,
|
||||
)
|
||||
|
||||
// Send each gift wrap as a NIP-17 message
|
||||
result.wraps.forEach { wrap ->
|
||||
// Broadcast through the account's NIP-17 send path
|
||||
// The wraps are already gift-wrapped, so we broadcast directly
|
||||
}
|
||||
account.sendGiftWraps(result.wraps)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user