mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-17 21:31:57 +01:00
Renames Gossip to Rumor to match names on the NIP-59
This commit is contained in:
parent
d1c64a0d15
commit
f3b049382e
@ -121,7 +121,7 @@ import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
|
||||
import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent
|
||||
import com.vitorpamplona.quartz.nip57Zaps.splits.ZapSplitSetup
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.WrappedEvent
|
||||
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||
import com.vitorpamplona.quartz.nip65RelayList.RelayUrlFormatter
|
||||
@ -3205,9 +3205,9 @@ class Account(
|
||||
|
||||
mine.forEach { giftWrap ->
|
||||
giftWrap.unwrap(signer) { gift ->
|
||||
if (gift is SealedGossipEvent) {
|
||||
gift.unseal(signer) { gossip ->
|
||||
LocalCache.justConsume(gossip, null)
|
||||
if (gift is SealedRumorEvent) {
|
||||
gift.unseal(signer) { rumor ->
|
||||
LocalCache.justConsume(rumor, null)
|
||||
}
|
||||
}
|
||||
|
||||
@ -3742,7 +3742,7 @@ class Account(
|
||||
}
|
||||
|
||||
fun unseal(
|
||||
event: SealedGossipEvent,
|
||||
event: SealedRumorEvent,
|
||||
onReady: (Event) -> Unit,
|
||||
) {
|
||||
if (!isWriteable()) return
|
||||
|
@ -123,7 +123,7 @@ import com.vitorpamplona.quartz.nip58Badges.BadgeAwardEvent
|
||||
import com.vitorpamplona.quartz.nip58Badges.BadgeDefinitionEvent
|
||||
import com.vitorpamplona.quartz.nip58Badges.BadgeProfilesEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.WrappedEvent
|
||||
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||
import com.vitorpamplona.quartz.nip68Picture.PictureEvent
|
||||
@ -1705,7 +1705,7 @@ object LocalCache {
|
||||
}
|
||||
|
||||
fun consume(
|
||||
event: SealedGossipEvent,
|
||||
event: SealedRumorEvent,
|
||||
relay: Relay?,
|
||||
) {
|
||||
val note = getOrCreateNote(event.id)
|
||||
@ -2562,7 +2562,7 @@ object LocalCache {
|
||||
event.containedPost()?.let { verifyAndConsume(it, relay) }
|
||||
consume(event)
|
||||
}
|
||||
is SealedGossipEvent -> consume(event, relay)
|
||||
is SealedRumorEvent -> consume(event, relay)
|
||||
is SearchRelayListEvent -> consume(event, relay)
|
||||
is StatusEvent -> consume(event, relay)
|
||||
is TextNoteEvent -> consume(event, relay)
|
||||
|
@ -65,7 +65,7 @@ import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
|
||||
import com.vitorpamplona.quartz.nip58Badges.BadgeAwardEvent
|
||||
import com.vitorpamplona.quartz.nip58Badges.BadgeProfilesEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||
import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent
|
||||
import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent
|
||||
@ -368,10 +368,10 @@ object NostrAccountDataSource : AmethystNostrDataSource("AccountData") {
|
||||
}
|
||||
}
|
||||
|
||||
is SealedGossipEvent -> {
|
||||
is SealedRumorEvent -> {
|
||||
// Avoid decrypting over and over again if the event already exist.
|
||||
val note = LocalCache.getNoteIfExists(event.id)
|
||||
val noteEvent = note?.event as? SealedGossipEvent
|
||||
val noteEvent = note?.event as? SealedRumorEvent
|
||||
if (noteEvent != null) {
|
||||
if (relay.brief !in note.relays) {
|
||||
LocalCache.justConsume(noteEvent, relay)
|
||||
@ -450,7 +450,7 @@ object NostrAccountDataSource : AmethystNostrDataSource("AccountData") {
|
||||
noteEvent.innerEventId?.let {
|
||||
markInnerAsSeenOnRelay(it, relay)
|
||||
}
|
||||
} else if (noteEvent is SealedGossipEvent) {
|
||||
} else if (noteEvent is SealedRumorEvent) {
|
||||
noteEvent.innerEventId?.let {
|
||||
markInnerAsSeenOnRelay(it, relay)
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ import com.vitorpamplona.quartz.nip55AndroidSigner.NostrSignerExternal
|
||||
import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
|
||||
import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
import java.math.BigDecimal
|
||||
import kotlin.coroutines.cancellation.CancellationException
|
||||
@ -184,7 +184,7 @@ class EventNotificationConsumer(
|
||||
LocalCache.justConsume(event, null)
|
||||
}
|
||||
}
|
||||
is SealedGossipEvent -> {
|
||||
is SealedRumorEvent -> {
|
||||
event.unseal(signer) {
|
||||
if (!LocalCache.hasConsumed(it)) {
|
||||
// this is not verifiable
|
||||
|
@ -104,7 +104,7 @@ import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
|
||||
import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent
|
||||
import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiserAmount
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||
import com.vitorpamplona.quartz.nip65RelayList.RelayUrlFormatter
|
||||
import com.vitorpamplona.quartz.nip90Dvms.NIP90ContentDiscoveryResponseEvent
|
||||
@ -958,7 +958,7 @@ class AccountViewModel(
|
||||
}
|
||||
|
||||
fun unseal(
|
||||
event: SealedGossipEvent,
|
||||
event: SealedRumorEvent,
|
||||
onReady: (Event) -> Unit,
|
||||
) {
|
||||
account.unseal(event, onReady)
|
||||
@ -1456,7 +1456,7 @@ class AccountViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
is SealedGossipEvent -> {
|
||||
is SealedRumorEvent -> {
|
||||
event.innerEventId?.let {
|
||||
val existingNote = LocalCache.getNoteIfExists(it)
|
||||
if (existingNote != null) {
|
||||
|
@ -52,7 +52,7 @@ import com.vitorpamplona.quartz.nip28PublicChat.ChannelMetadataEvent
|
||||
import com.vitorpamplona.quartz.nip53LiveActivities.LiveActivitiesChatMessageEvent
|
||||
import com.vitorpamplona.quartz.nip53LiveActivities.LiveActivitiesEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@ -149,7 +149,7 @@ fun redirect(
|
||||
} ?: run {
|
||||
accountViewModel.unwrap(event) { redirect(it, accountViewModel, nav) }
|
||||
}
|
||||
} else if (event is SealedGossipEvent) {
|
||||
} else if (event is SealedRumorEvent) {
|
||||
event.innerEventId?.let {
|
||||
redirect(it, accountViewModel, nav)
|
||||
} ?: run {
|
||||
|
@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
|
||||
import com.vitorpamplona.quartz.nip17Dm.NIP17Factory
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import junit.framework.TestCase
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.assertTrue
|
||||
@ -89,8 +89,8 @@ class GiftWrapBenchmark {
|
||||
it.cachedGift(keyToUse) { event ->
|
||||
event.checkSignature()
|
||||
|
||||
if (event is SealedGossipEvent) {
|
||||
event.cachedGossip(keyToUse) { innerData ->
|
||||
if (event is SealedRumorEvent) {
|
||||
event.cachedRumor(keyToUse) { innerData ->
|
||||
Assert.assertEquals(message, innerData.content)
|
||||
countDownLatch2.countDown()
|
||||
}
|
||||
@ -135,8 +135,8 @@ class GiftWrapBenchmark {
|
||||
wrap.cachedGift(keyToUse) { seal ->
|
||||
seal.checkSignature()
|
||||
|
||||
if (seal is SealedGossipEvent) {
|
||||
seal.cachedGossip(keyToUse) { innerData ->
|
||||
if (seal is SealedRumorEvent) {
|
||||
seal.cachedRumor(keyToUse) { innerData ->
|
||||
Assert.assertEquals(message, innerData.content)
|
||||
counter.countDown()
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
|
||||
import com.vitorpamplona.quartz.nip17Dm.ChatMessageEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.Gossip
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.Rumor
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import junit.framework.TestCase.assertNotNull
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Rule
|
||||
@ -73,7 +73,7 @@ class GiftWrapReceivingBenchmark {
|
||||
isDraft = true,
|
||||
signer = sender,
|
||||
) {
|
||||
SealedGossipEvent.create(
|
||||
SealedRumorEvent.create(
|
||||
event = it,
|
||||
encryptTo = receiver.pubKey,
|
||||
signer = sender,
|
||||
@ -96,9 +96,9 @@ class GiftWrapReceivingBenchmark {
|
||||
fun createSeal(
|
||||
sender: NostrSigner,
|
||||
receiver: NostrSigner,
|
||||
): SealedGossipEvent {
|
||||
): SealedRumorEvent {
|
||||
val countDownLatch = CountDownLatch(1)
|
||||
var seal: SealedGossipEvent? = null
|
||||
var seal: SealedRumorEvent? = null
|
||||
|
||||
ChatMessageEvent.create(
|
||||
msg = "Hi there! This is a test message",
|
||||
@ -113,7 +113,7 @@ class GiftWrapReceivingBenchmark {
|
||||
isDraft = true,
|
||||
signer = sender,
|
||||
) {
|
||||
SealedGossipEvent.create(
|
||||
SealedRumorEvent.create(
|
||||
event = it,
|
||||
encryptTo = receiver.pubKey,
|
||||
signer = sender,
|
||||
@ -225,6 +225,6 @@ class GiftWrapReceivingBenchmark {
|
||||
seal.pubKey.hexToByteArray(),
|
||||
)
|
||||
|
||||
benchmarkRule.measureRepeated { assertNotNull(innerJson?.let { Gossip.fromJson(it) }) }
|
||||
benchmarkRule.measureRepeated { assertNotNull(innerJson?.let { Rumor.fromJson(it) }) }
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.KeyPair
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
|
||||
import com.vitorpamplona.quartz.nip17Dm.ChatMessageEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@ -103,7 +103,7 @@ class GiftWrapSigningBenchmark {
|
||||
|
||||
benchmarkRule.measureRepeated {
|
||||
val countDownLatch2 = CountDownLatch(1)
|
||||
SealedGossipEvent.create(
|
||||
SealedRumorEvent.create(
|
||||
event = msg!!,
|
||||
encryptTo = receiver.pubKey,
|
||||
signer = sender,
|
||||
@ -122,7 +122,7 @@ class GiftWrapSigningBenchmark {
|
||||
|
||||
val countDownLatch = CountDownLatch(1)
|
||||
|
||||
var seal: SealedGossipEvent? = null
|
||||
var seal: SealedRumorEvent? = null
|
||||
|
||||
ChatMessageEvent.create(
|
||||
msg = "Hi there! This is a test message",
|
||||
@ -137,7 +137,7 @@ class GiftWrapSigningBenchmark {
|
||||
isDraft = false,
|
||||
signer = sender,
|
||||
) {
|
||||
SealedGossipEvent.create(
|
||||
SealedRumorEvent.create(
|
||||
event = it,
|
||||
encryptTo = receiver.pubKey,
|
||||
signer = sender,
|
||||
@ -183,7 +183,7 @@ class GiftWrapSigningBenchmark {
|
||||
isDraft = false,
|
||||
signer = sender,
|
||||
) {
|
||||
SealedGossipEvent.create(
|
||||
SealedRumorEvent.create(
|
||||
event = it,
|
||||
encryptTo = receiver.pubKey,
|
||||
signer = sender,
|
||||
|
@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser
|
||||
import com.vitorpamplona.quartz.nip17Dm.ChatMessageEvent
|
||||
import com.vitorpamplona.quartz.nip17Dm.NIP17Factory
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.utils.Hex
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotEquals
|
||||
@ -65,8 +65,8 @@ class GiftWrapEventTest {
|
||||
val eventsReceiverGets = events.wraps.filter { it.isTaggedUser(receiver.pubKey) }
|
||||
eventsReceiverGets.forEach {
|
||||
it.cachedGift(receiver) { event ->
|
||||
if (event is SealedGossipEvent) {
|
||||
event.cachedGossip(receiver) { innerData ->
|
||||
if (event is SealedRumorEvent) {
|
||||
event.cachedRumor(receiver) { innerData ->
|
||||
countDownLatch.countDown()
|
||||
assertEquals(message, innerData.content)
|
||||
}
|
||||
@ -80,8 +80,8 @@ class GiftWrapEventTest {
|
||||
val eventsSenderGets = events.wraps.filter { it.isTaggedUser(sender.pubKey) }
|
||||
eventsSenderGets.forEach {
|
||||
it.cachedGift(sender) { event ->
|
||||
if (event is SealedGossipEvent) {
|
||||
event.cachedGossip(sender) { innerData ->
|
||||
if (event is SealedRumorEvent) {
|
||||
event.cachedRumor(sender) { innerData ->
|
||||
countDownLatch.countDown()
|
||||
assertEquals(message, innerData.content)
|
||||
}
|
||||
@ -126,8 +126,8 @@ class GiftWrapEventTest {
|
||||
val eventsReceiverGets = events.wraps.filter { it.isTaggedUser(receiver.pubKey) }
|
||||
eventsReceiverGets.forEach {
|
||||
it.cachedGift(receiver) { event ->
|
||||
if (event is SealedGossipEvent) {
|
||||
event.cachedGossip(receiver) { innerData ->
|
||||
if (event is SealedRumorEvent) {
|
||||
event.cachedRumor(receiver) { innerData ->
|
||||
countDownLatch.countDown()
|
||||
assertEquals(message, innerData.content)
|
||||
}
|
||||
@ -142,8 +142,8 @@ class GiftWrapEventTest {
|
||||
val eventsSenderGets = events.wraps.filter { it.isTaggedUser(sender.pubKey) }
|
||||
eventsSenderGets.forEach {
|
||||
it.cachedGift(sender) { event ->
|
||||
if (event is SealedGossipEvent) {
|
||||
event.cachedGossip(sender) { innerData ->
|
||||
if (event is SealedRumorEvent) {
|
||||
event.cachedRumor(sender) { innerData ->
|
||||
countDownLatch.countDown()
|
||||
assertEquals(message, innerData.content)
|
||||
}
|
||||
@ -175,7 +175,7 @@ class GiftWrapEventTest {
|
||||
) { senderMessage ->
|
||||
// MsgFor the Receiver
|
||||
|
||||
SealedGossipEvent.create(
|
||||
SealedRumorEvent.create(
|
||||
event = senderMessage,
|
||||
encryptTo = receiver.pubKey,
|
||||
signer = sender,
|
||||
@ -206,7 +206,7 @@ class GiftWrapEventTest {
|
||||
}
|
||||
|
||||
// MsgFor the Sender
|
||||
SealedGossipEvent.create(
|
||||
SealedRumorEvent.create(
|
||||
event = senderMessage,
|
||||
encryptTo = sender.pubKey,
|
||||
signer = sender,
|
||||
@ -248,16 +248,16 @@ class GiftWrapEventTest {
|
||||
val countDownDecryptLatch = CountDownLatch(2)
|
||||
|
||||
giftWrapEventToSender!!.cachedGift(sender) { unwrappedMsgForSenderBySender ->
|
||||
assertEquals(SealedGossipEvent.KIND, unwrappedMsgForSenderBySender.kind)
|
||||
assertTrue(unwrappedMsgForSenderBySender is SealedGossipEvent)
|
||||
assertEquals(SealedRumorEvent.KIND, unwrappedMsgForSenderBySender.kind)
|
||||
assertTrue(unwrappedMsgForSenderBySender is SealedRumorEvent)
|
||||
|
||||
if (unwrappedMsgForSenderBySender is SealedGossipEvent) {
|
||||
unwrappedMsgForSenderBySender.cachedGossip(sender) { unwrappedGossipToSenderBySender ->
|
||||
assertEquals("Hi There!", unwrappedGossipToSenderBySender.content)
|
||||
if (unwrappedMsgForSenderBySender is SealedRumorEvent) {
|
||||
unwrappedMsgForSenderBySender.cachedRumor(sender) { unwrappedRumorToSenderBySender ->
|
||||
assertEquals("Hi There!", unwrappedRumorToSenderBySender.content)
|
||||
countDownDecryptLatch.countDown()
|
||||
}
|
||||
|
||||
unwrappedMsgForSenderBySender.cachedGossip(receiver) { _ ->
|
||||
unwrappedMsgForSenderBySender.cachedRumor(receiver) { _ ->
|
||||
fail(
|
||||
"Should not be able to decrypt msg for the sender by the sender but decrypted with receiver",
|
||||
)
|
||||
@ -274,16 +274,16 @@ class GiftWrapEventTest {
|
||||
}
|
||||
|
||||
giftWrapEventToReceiver!!.cachedGift(receiver) { unwrappedMsgForReceiverByReceiver ->
|
||||
assertEquals(SealedGossipEvent.KIND, unwrappedMsgForReceiverByReceiver.kind)
|
||||
assertTrue(unwrappedMsgForReceiverByReceiver is SealedGossipEvent)
|
||||
assertEquals(SealedRumorEvent.KIND, unwrappedMsgForReceiverByReceiver.kind)
|
||||
assertTrue(unwrappedMsgForReceiverByReceiver is SealedRumorEvent)
|
||||
|
||||
if (unwrappedMsgForReceiverByReceiver is SealedGossipEvent) {
|
||||
unwrappedMsgForReceiverByReceiver.cachedGossip(receiver) { unwrappedGossipToReceiverByReceiver ->
|
||||
assertEquals("Hi There!", unwrappedGossipToReceiverByReceiver?.content)
|
||||
if (unwrappedMsgForReceiverByReceiver is SealedRumorEvent) {
|
||||
unwrappedMsgForReceiverByReceiver.cachedRumor(receiver) { unwrappedRumorToReceiverByReceiver ->
|
||||
assertEquals("Hi There!", unwrappedRumorToReceiverByReceiver?.content)
|
||||
countDownDecryptLatch.countDown()
|
||||
}
|
||||
|
||||
unwrappedMsgForReceiverByReceiver.cachedGossip(sender) { unwrappedGossipToReceiverBySender ->
|
||||
unwrappedMsgForReceiverByReceiver.cachedRumor(sender) { unwrappedRumorToReceiverBySender ->
|
||||
fail(
|
||||
"Should not be able to decrypt msg for the receiver by the receiver but decrypted with the sender",
|
||||
)
|
||||
@ -312,7 +312,7 @@ class GiftWrapEventTest {
|
||||
to = listOf(receiverA.pubKey, receiverB.pubKey),
|
||||
signer = sender,
|
||||
) { senderMessage ->
|
||||
SealedGossipEvent.create(
|
||||
SealedRumorEvent.create(
|
||||
event = senderMessage,
|
||||
encryptTo = receiverA.pubKey,
|
||||
signer = sender,
|
||||
@ -343,7 +343,7 @@ class GiftWrapEventTest {
|
||||
}
|
||||
}
|
||||
|
||||
SealedGossipEvent.create(
|
||||
SealedRumorEvent.create(
|
||||
event = senderMessage,
|
||||
encryptTo = receiverB.pubKey,
|
||||
signer = sender,
|
||||
@ -374,7 +374,7 @@ class GiftWrapEventTest {
|
||||
}
|
||||
}
|
||||
|
||||
SealedGossipEvent.create(
|
||||
SealedRumorEvent.create(
|
||||
event = senderMessage,
|
||||
encryptTo = sender.pubKey,
|
||||
signer = sender,
|
||||
@ -419,21 +419,21 @@ class GiftWrapEventTest {
|
||||
val countDownDecryptLatch = CountDownLatch(3)
|
||||
|
||||
giftWrapEventToSender?.cachedGift(sender) { unwrappedMsgForSenderBySender ->
|
||||
assertEquals(SealedGossipEvent.KIND, unwrappedMsgForSenderBySender.kind)
|
||||
assertEquals(SealedRumorEvent.KIND, unwrappedMsgForSenderBySender.kind)
|
||||
|
||||
if (unwrappedMsgForSenderBySender is SealedGossipEvent) {
|
||||
unwrappedMsgForSenderBySender.cachedGossip(receiverA) { unwrappedGossipToSenderByReceiverA ->
|
||||
if (unwrappedMsgForSenderBySender is SealedRumorEvent) {
|
||||
unwrappedMsgForSenderBySender.cachedRumor(receiverA) { unwrappedRumorToSenderByReceiverA ->
|
||||
fail()
|
||||
}
|
||||
|
||||
unwrappedMsgForSenderBySender.cachedGossip(receiverB) { unwrappedGossipToSenderByReceiverB ->
|
||||
unwrappedMsgForSenderBySender.cachedRumor(receiverB) { unwrappedRumorToSenderByReceiverB ->
|
||||
fail()
|
||||
}
|
||||
|
||||
unwrappedMsgForSenderBySender.cachedGossip(sender) { unwrappedGossipToSenderBySender ->
|
||||
unwrappedMsgForSenderBySender.cachedRumor(sender) { unwrappedRumorToSenderBySender ->
|
||||
assertEquals(
|
||||
"Who is going to the party tonight?",
|
||||
unwrappedGossipToSenderBySender.content,
|
||||
unwrappedRumorToSenderBySender.content,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -454,21 +454,21 @@ class GiftWrapEventTest {
|
||||
}
|
||||
|
||||
giftWrapEventToReceiverA!!.cachedGift(receiverA) { unwrappedMsgForReceiverAByReceiverA ->
|
||||
assertEquals(SealedGossipEvent.KIND, unwrappedMsgForReceiverAByReceiverA.kind)
|
||||
assertEquals(SealedRumorEvent.KIND, unwrappedMsgForReceiverAByReceiverA.kind)
|
||||
|
||||
if (unwrappedMsgForReceiverAByReceiverA is SealedGossipEvent) {
|
||||
unwrappedMsgForReceiverAByReceiverA.cachedGossip(receiverA) { unwrappedGossipToReceiverAByReceiverA ->
|
||||
if (unwrappedMsgForReceiverAByReceiverA is SealedRumorEvent) {
|
||||
unwrappedMsgForReceiverAByReceiverA.cachedRumor(receiverA) { unwrappedRumorToReceiverAByReceiverA ->
|
||||
assertEquals(
|
||||
"Who is going to the party tonight?",
|
||||
unwrappedGossipToReceiverAByReceiverA.content,
|
||||
unwrappedRumorToReceiverAByReceiverA.content,
|
||||
)
|
||||
}
|
||||
|
||||
unwrappedMsgForReceiverAByReceiverA.cachedGossip(sender) { unwrappedGossipToReceiverABySender ->
|
||||
unwrappedMsgForReceiverAByReceiverA.cachedRumor(sender) { unwrappedRumorToReceiverABySender ->
|
||||
fail()
|
||||
}
|
||||
|
||||
unwrappedMsgForReceiverAByReceiverA.cachedGossip(receiverB) { unwrappedGossipToReceiverAByReceiverB ->
|
||||
unwrappedMsgForReceiverAByReceiverA.cachedRumor(receiverB) { unwrappedRumorToReceiverAByReceiverB ->
|
||||
fail()
|
||||
}
|
||||
}
|
||||
@ -487,23 +487,23 @@ class GiftWrapEventTest {
|
||||
fail("Should not be able to decode msg to receiver A with the receiver B's key")
|
||||
}
|
||||
giftWrapEventToReceiverB!!.cachedGift(receiverB) { unwrappedMsgForReceiverBByReceiverB ->
|
||||
assertEquals(SealedGossipEvent.KIND, unwrappedMsgForReceiverBByReceiverB.kind)
|
||||
assertEquals(SealedRumorEvent.KIND, unwrappedMsgForReceiverBByReceiverB.kind)
|
||||
|
||||
if (unwrappedMsgForReceiverBByReceiverB is SealedGossipEvent) {
|
||||
unwrappedMsgForReceiverBByReceiverB.cachedGossip(receiverA) { unwrappedGossipToReceiverBByReceiverA ->
|
||||
if (unwrappedMsgForReceiverBByReceiverB is SealedRumorEvent) {
|
||||
unwrappedMsgForReceiverBByReceiverB.cachedRumor(receiverA) { unwrappedRumorToReceiverBByReceiverA ->
|
||||
fail()
|
||||
}
|
||||
|
||||
unwrappedMsgForReceiverBByReceiverB.cachedGossip(receiverB) { unwrappedGossipToReceiverBByReceiverB ->
|
||||
unwrappedMsgForReceiverBByReceiverB.cachedRumor(receiverB) { unwrappedRumorToReceiverBByReceiverB ->
|
||||
assertEquals(
|
||||
"Who is going to the party tonight?",
|
||||
unwrappedGossipToReceiverBByReceiverB.content,
|
||||
unwrappedRumorToReceiverBByReceiverB.content,
|
||||
)
|
||||
|
||||
countDownDecryptLatch.countDown()
|
||||
}
|
||||
|
||||
unwrappedMsgForReceiverBByReceiverB.cachedGossip(sender) { unwrappedGossipToReceiverBBySender ->
|
||||
unwrappedMsgForReceiverBByReceiverB.cachedRumor(sender) { unwrappedRumorToReceiverBBySender ->
|
||||
fail()
|
||||
}
|
||||
}
|
||||
@ -532,18 +532,18 @@ class GiftWrapEventTest {
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
var gossip: Event? = null
|
||||
var rumor: Event? = null
|
||||
|
||||
wait1SecondForResult { onDone ->
|
||||
val privateKey = "de6152a85a0dea3b09a08a6f8139a314d498a7b52f7e5c28858b64270abd4c70"
|
||||
unwrapUnsealGossip(json, privateKey) {
|
||||
gossip = it
|
||||
unwrapUnsealRumor(json, privateKey) {
|
||||
rumor = it
|
||||
onDone()
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull(gossip)
|
||||
assertEquals("Hola, que tal?", gossip?.content)
|
||||
assertNotNull(rumor)
|
||||
assertEquals("Hola, que tal?", rumor?.content)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -568,17 +568,17 @@ class GiftWrapEventTest {
|
||||
|
||||
val privateKey = "409ff7654141eaa16cd2161fe5bd127aeaef71f270c67587474b78998a8e3533"
|
||||
|
||||
var gossip: Event? = null
|
||||
var rumor: Event? = null
|
||||
|
||||
wait1SecondForResult { onDone ->
|
||||
unwrapUnsealGossip(json, privateKey) {
|
||||
gossip = it
|
||||
unwrapUnsealRumor(json, privateKey) {
|
||||
rumor = it
|
||||
onDone()
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull(gossip)
|
||||
assertEquals("Hola, que tal?", gossip?.content)
|
||||
assertNotNull(rumor)
|
||||
assertEquals("Hola, que tal?", rumor?.content)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -605,17 +605,17 @@ class GiftWrapEventTest {
|
||||
""".trimIndent()
|
||||
|
||||
val privateKey = "09e0051fdf5fdd9dd7a54713583006442cbdbf87bdcdab1a402f26e527d56771"
|
||||
var gossip: Event? = null
|
||||
var rumor: Event? = null
|
||||
|
||||
wait1SecondForResult { onDone ->
|
||||
unwrapUnsealGossip(json, privateKey) {
|
||||
gossip = it
|
||||
unwrapUnsealRumor(json, privateKey) {
|
||||
rumor = it
|
||||
onDone()
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull(gossip)
|
||||
assertEquals("test", gossip?.content)
|
||||
assertNotNull(rumor)
|
||||
assertEquals("test", rumor?.content)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -640,21 +640,21 @@ class GiftWrapEventTest {
|
||||
|
||||
val privateKey = "09e0051fdf5fdd9dd7a54713583006442cbdbf87bdcdab1a402f26e527d56771"
|
||||
|
||||
var gossip: Event? = null
|
||||
var rumor: Event? = null
|
||||
|
||||
wait1SecondForResult { onDone ->
|
||||
unwrapUnsealGossip(json, privateKey) {
|
||||
gossip = it
|
||||
unwrapUnsealRumor(json, privateKey) {
|
||||
rumor = it
|
||||
onDone()
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals("asdfasdfasdf", gossip?.content)
|
||||
assertEquals(1690659269L, gossip?.createdAt)
|
||||
assertEquals("827ba09d32ab81d62c60f657b350198c8aaba84372dab9ad3f4f6b8b7274b707", gossip?.id)
|
||||
assertEquals(14, gossip?.kind)
|
||||
assertEquals("subject", gossip?.tags?.firstOrNull()?.get(0))
|
||||
assertEquals("test", gossip?.tags?.firstOrNull()?.get(1))
|
||||
assertEquals("asdfasdfasdf", rumor?.content)
|
||||
assertEquals(1690659269L, rumor?.createdAt)
|
||||
assertEquals("827ba09d32ab81d62c60f657b350198c8aaba84372dab9ad3f4f6b8b7274b707", rumor?.id)
|
||||
assertEquals(14, rumor?.kind)
|
||||
assertEquals("subject", rumor?.tags?.firstOrNull()?.get(0))
|
||||
assertEquals("test", rumor?.tags?.firstOrNull()?.get(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -679,29 +679,29 @@ class GiftWrapEventTest {
|
||||
|
||||
val privateKey = "7dd22cafc512c0bc363a259f6dcda515b13ae3351066d7976fd0bb79cbd0d700"
|
||||
|
||||
var gossip: Event? = null
|
||||
var rumor: Event? = null
|
||||
|
||||
wait1SecondForResult { onDone ->
|
||||
unwrapUnsealGossip(json, privateKey) {
|
||||
gossip = it
|
||||
unwrapUnsealRumor(json, privateKey) {
|
||||
rumor = it
|
||||
onDone()
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals("8d1a56008d4e31dae2fb8bef36b3efea519eff75f57033107e2aa16702466ef2", gossip?.id)
|
||||
assertEquals("Howdy", gossip?.content)
|
||||
assertEquals(1690833960L, gossip?.createdAt)
|
||||
assertEquals(14, gossip?.kind)
|
||||
assertEquals("p", gossip?.tags?.firstOrNull()?.get(0))
|
||||
assertEquals("8d1a56008d4e31dae2fb8bef36b3efea519eff75f57033107e2aa16702466ef2", rumor?.id)
|
||||
assertEquals("Howdy", rumor?.content)
|
||||
assertEquals(1690833960L, rumor?.createdAt)
|
||||
assertEquals(14, rumor?.kind)
|
||||
assertEquals("p", rumor?.tags?.firstOrNull()?.get(0))
|
||||
assertEquals(
|
||||
"b08d8857a92b4d6aa580ff55cc3c18c4edf313c83388c34abc118621f74f1a78",
|
||||
gossip?.tags?.firstOrNull()?.get(1),
|
||||
rumor?.tags?.firstOrNull()?.get(1),
|
||||
)
|
||||
assertEquals("subject", gossip?.tags?.getOrNull(1)?.get(0))
|
||||
assertEquals("Stuff", gossip?.tags?.getOrNull(1)?.get(1))
|
||||
assertEquals("subject", rumor?.tags?.getOrNull(1)?.get(0))
|
||||
assertEquals("Stuff", rumor?.tags?.getOrNull(1)?.get(1))
|
||||
}
|
||||
|
||||
fun unwrapUnsealGossip(
|
||||
fun unwrapUnsealRumor(
|
||||
json: String,
|
||||
privateKey: HexKey,
|
||||
onReady: (Event) -> Unit,
|
||||
@ -714,11 +714,11 @@ class GiftWrapEventTest {
|
||||
assertEquals(pkBytes.pubKey, wrap.recipientPubKey())
|
||||
|
||||
wrap.cachedGift(pkBytes) { event ->
|
||||
if (event is SealedGossipEvent) {
|
||||
event.cachedGossip(pkBytes, onReady)
|
||||
if (event is SealedRumorEvent) {
|
||||
event.cachedRumor(pkBytes, onReady)
|
||||
} else {
|
||||
println(event.toJson())
|
||||
fail("Event is not a Sealed Gossip")
|
||||
fail("Event is not a Sealed Rumor")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ import com.vitorpamplona.quartz.nip58Badges.BadgeAwardEvent
|
||||
import com.vitorpamplona.quartz.nip58Badges.BadgeDefinitionEvent
|
||||
import com.vitorpamplona.quartz.nip58Badges.BadgeProfilesEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||
import com.vitorpamplona.quartz.nip68Picture.PictureEvent
|
||||
import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent
|
||||
@ -242,7 +242,7 @@ class EventFactory {
|
||||
RelaySetEvent.KIND -> RelaySetEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
ReportEvent.KIND -> ReportEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
RepostEvent.KIND -> RepostEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
SealedGossipEvent.KIND -> SealedGossipEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
SealedRumorEvent.KIND -> SealedRumorEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
SearchRelayListEvent.KIND -> SearchRelayListEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
StatusEvent.KIND -> StatusEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
TextNoteEvent.KIND -> TextNoteEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
|
@ -35,9 +35,9 @@ import com.vitorpamplona.quartz.nip47WalletConnect.Request
|
||||
import com.vitorpamplona.quartz.nip47WalletConnect.RequestDeserializer
|
||||
import com.vitorpamplona.quartz.nip47WalletConnect.Response
|
||||
import com.vitorpamplona.quartz.nip47WalletConnect.ResponseDeserializer
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.Gossip
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GossipDeserializer
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GossipSerializer
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.Rumor
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.RumorDeserializer
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.RumorSerializer
|
||||
|
||||
class EventMapper {
|
||||
companion object {
|
||||
@ -49,8 +49,8 @@ class EventMapper {
|
||||
SimpleModule()
|
||||
.addSerializer(Event::class.java, EventSerializer())
|
||||
.addDeserializer(Event::class.java, EventDeserializer())
|
||||
.addSerializer(Gossip::class.java, GossipSerializer())
|
||||
.addDeserializer(Gossip::class.java, GossipDeserializer())
|
||||
.addSerializer(Rumor::class.java, RumorSerializer())
|
||||
.addDeserializer(Rumor::class.java, RumorDeserializer())
|
||||
.addDeserializer(Response::class.java, ResponseDeserializer())
|
||||
.addDeserializer(Request::class.java, RequestDeserializer())
|
||||
.addDeserializer(BunkerMessage::class.java, BunkerMessage.BunkerMessageDeserializer())
|
||||
|
@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent
|
||||
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
|
||||
import com.vitorpamplona.quartz.nip57Zaps.splits.ZapSplitSetup
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip92IMeta.IMetaTag
|
||||
import com.vitorpamplona.quartz.nip94FileMetadata.Dimension
|
||||
|
||||
@ -51,7 +51,7 @@ class NIP17Factory {
|
||||
|
||||
val next = remainingTos.first()
|
||||
|
||||
SealedGossipEvent.create(
|
||||
SealedRumorEvent.create(
|
||||
event = event,
|
||||
encryptTo = next,
|
||||
signer = signer,
|
||||
|
@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.EventMapper
|
||||
|
||||
class Gossip(
|
||||
class Rumor(
|
||||
val id: HexKey?,
|
||||
@JsonProperty("pubkey") val pubKey: HexKey?,
|
||||
@JsonProperty("created_at") val createdAt: Long?,
|
||||
@ -35,7 +35,7 @@ class Gossip(
|
||||
val tags: Array<Array<String>>?,
|
||||
val content: String?,
|
||||
) {
|
||||
fun mergeWith(event: SealedGossipEvent): Event {
|
||||
fun mergeWith(event: SealedRumorEvent): Event {
|
||||
val newPubKey = event.pubKey // forces to be the pubkey of the seal to make sure impersonators don't impersonate
|
||||
val newCreatedAt = if (createdAt != null && createdAt > 1000) createdAt else event.createdAt
|
||||
val newKind = kind ?: -1
|
||||
@ -48,10 +48,10 @@ class Gossip(
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun fromJson(json: String): Gossip = EventMapper.mapper.readValue(json, Gossip::class.java)
|
||||
fun fromJson(json: String): Rumor = EventMapper.mapper.readValue(json, Rumor::class.java)
|
||||
|
||||
fun toJson(event: Gossip): String = EventMapper.mapper.writeValueAsString(event)
|
||||
fun toJson(event: Rumor): String = EventMapper.mapper.writeValueAsString(event)
|
||||
|
||||
fun create(event: Event): Gossip = Gossip(event.id, event.pubKey, event.createdAt, event.kind, event.tags, event.content)
|
||||
fun create(event: Event): Rumor = Rumor(event.id, event.pubKey, event.createdAt, event.kind, event.tags, event.content)
|
||||
}
|
||||
}
|
@ -26,13 +26,13 @@ import com.fasterxml.jackson.databind.JsonNode
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.toTypedArray
|
||||
|
||||
class GossipDeserializer : StdDeserializer<Gossip>(Gossip::class.java) {
|
||||
class RumorDeserializer : StdDeserializer<Rumor>(Rumor::class.java) {
|
||||
override fun deserialize(
|
||||
jp: JsonParser,
|
||||
ctxt: DeserializationContext,
|
||||
): Gossip {
|
||||
): Rumor {
|
||||
val jsonObject: JsonNode = jp.codec.readTree(jp)
|
||||
return Gossip(
|
||||
return Rumor(
|
||||
id = jsonObject.get("id")?.asText()?.intern(),
|
||||
pubKey = jsonObject.get("pubkey")?.asText()?.intern(),
|
||||
createdAt = jsonObject.get("created_at")?.asLong(),
|
@ -24,9 +24,9 @@ import com.fasterxml.jackson.core.JsonGenerator
|
||||
import com.fasterxml.jackson.databind.SerializerProvider
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer
|
||||
|
||||
class GossipSerializer : StdSerializer<Gossip>(Gossip::class.java) {
|
||||
class RumorSerializer : StdSerializer<Rumor>(Rumor::class.java) {
|
||||
override fun serialize(
|
||||
event: Gossip,
|
||||
event: Rumor,
|
||||
gen: JsonGenerator,
|
||||
provider: SerializerProvider,
|
||||
) {
|
@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.utils.bytesUsedInMemory
|
||||
import com.vitorpamplona.quartz.utils.pointerSizeInBytes
|
||||
|
||||
@Immutable
|
||||
class SealedGossipEvent(
|
||||
class SealedRumorEvent(
|
||||
id: HexKey,
|
||||
pubKey: HexKey,
|
||||
createdAt: Long,
|
||||
@ -44,9 +44,9 @@ class SealedGossipEvent(
|
||||
super.countMemory() +
|
||||
pointerSizeInBytes + (innerEventId?.bytesUsedInMemory() ?: 0)
|
||||
|
||||
fun copyNoContent(): SealedGossipEvent {
|
||||
fun copyNoContent(): SealedRumorEvent {
|
||||
val copy =
|
||||
SealedGossipEvent(
|
||||
SealedRumorEvent(
|
||||
id,
|
||||
pubKey,
|
||||
createdAt,
|
||||
@ -67,7 +67,7 @@ class SealedGossipEvent(
|
||||
message = "Heavy caching was removed from this class due to high memory use. Cache it separatedly",
|
||||
replaceWith = ReplaceWith("unseal"),
|
||||
)
|
||||
fun cachedGossip(
|
||||
fun cachedRumor(
|
||||
signer: NostrSigner,
|
||||
onReady: (Event) -> Unit,
|
||||
) = unseal(signer, onReady)
|
||||
@ -79,8 +79,8 @@ class SealedGossipEvent(
|
||||
try {
|
||||
plainContent(signer) {
|
||||
try {
|
||||
val gossip = Gossip.fromJson(it)
|
||||
val event = gossip.mergeWith(this)
|
||||
val rumor = Rumor.fromJson(it)
|
||||
val event = rumor.mergeWith(this)
|
||||
if (event is WrappedEvent) {
|
||||
event.host = host ?: HostStub(this.id, this.pubKey, this.kind)
|
||||
}
|
||||
@ -88,11 +88,11 @@ class SealedGossipEvent(
|
||||
|
||||
onReady(event)
|
||||
} catch (e: Exception) {
|
||||
Log.w("GossipEvent", "Fail to decrypt or parse Gossip", e)
|
||||
Log.w("RumorEvent", "Fail to decrypt or parse Rumor", e)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w("GossipEvent", "Fail to decrypt or parse Gossip", e)
|
||||
Log.w("RumorEvent", "Fail to decrypt or parse Rumor", e)
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,20 +113,20 @@ class SealedGossipEvent(
|
||||
encryptTo: HexKey,
|
||||
signer: NostrSigner,
|
||||
createdAt: Long = TimeUtils.now(),
|
||||
onReady: (SealedGossipEvent) -> Unit,
|
||||
onReady: (SealedRumorEvent) -> Unit,
|
||||
) {
|
||||
val gossip = Gossip.create(event)
|
||||
create(gossip, encryptTo, signer, createdAt, onReady)
|
||||
val rumor = Rumor.create(event)
|
||||
create(rumor, encryptTo, signer, createdAt, onReady)
|
||||
}
|
||||
|
||||
fun create(
|
||||
gossip: Gossip,
|
||||
rumor: Rumor,
|
||||
encryptTo: HexKey,
|
||||
signer: NostrSigner,
|
||||
createdAt: Long = TimeUtils.randomWithTwoDays(),
|
||||
onReady: (SealedGossipEvent) -> Unit,
|
||||
onReady: (SealedRumorEvent) -> Unit,
|
||||
) {
|
||||
val msg = Gossip.toJson(gossip)
|
||||
val msg = Rumor.toJson(rumor)
|
||||
|
||||
signer.nip44Encrypt(msg, encryptTo) { content ->
|
||||
signer.sign(createdAt, KIND, emptyArray(), content, onReady)
|
Loading…
x
Reference in New Issue
Block a user