Improve logging

This commit is contained in:
Kgothatso Ngako
2026-06-03 01:21:11 +02:00
parent 62582e7569
commit 1ab17510cf
2 changed files with 17 additions and 11 deletions

View File

@@ -79,7 +79,6 @@ abstract class NostrNip17Dao(
giftWrapEvent: GiftWrapEvent,
receiverPublicKey: PTag
) {
val nostrEvent = NostrEvent(
id = giftWrapEvent.id,
content = giftWrapEvent.content,
@@ -89,6 +88,7 @@ abstract class NostrNip17Dao(
tags = giftWrapEvent.tags,
kind = giftWrapEvent.kind
)
logger.d("NostrEvent: $nostrEvent")
database.nostrEventDao().insert(nostrEvent)
@@ -120,17 +120,18 @@ abstract class NostrNip17Dao(
)
)
val giftWrapSeal = GiftWrapSeal(
id = sealedRumorEvent.id,
publicKey = sealedRumorEvent.pubKey,
content = sealedRumorEvent.content,
kind = sealedRumorEvent.kind,
tags = sealedRumorEvent.tags,
signature = sealedRumorEvent.sig,
giftWrapMessageId = giftWrapEvent.id
database.giftWrapSealDao().upsert(
GiftWrapSeal(
id = sealedRumorEvent.id,
publicKey = sealedRumorEvent.pubKey,
content = sealedRumorEvent.content,
kind = sealedRumorEvent.kind,
tags = sealedRumorEvent.tags,
signature = sealedRumorEvent.sig,
giftWrapMessageId = giftWrapEvent.id
)
)
database.giftWrapSealDao().upsert(giftWrapSeal)
logger.d("persistAndBroadcastGiftWrap done")
}
companion object {

View File

@@ -107,8 +107,10 @@ class DatabaseChatRepository(
tags = giftWrapPayload.tags,
content = giftWrapPayload.content
)
logger.d("GiftWrap Payload Event: ${giftWrapPayloadEvent.toJson()}")
giftWrapPayload.tags.taggedUsers().forEachIndexed { index, receiverPublicKey ->
logger.d("Seal to $receiverPublicKey")
val payload = giftWrapPayloadEvent.toJson()
val sealedRumorEvent = nostrSignerSync.signNormal<SealedRumorEvent>(
@@ -120,6 +122,7 @@ class DatabaseChatRepository(
toPublicKey = receiverPublicKey.pubKey
)
)
logger.d("SealedRumorEvent: ${sealedRumorEvent.toJson()}")
val giftWrapEvent = nostrSignerSync.signNormal<GiftWrapEvent>(
createdAt = TimeUtils.randomWithTwoDays(),
@@ -132,6 +135,7 @@ class DatabaseChatRepository(
toPublicKey = receiverPublicKey.pubKey
)
)
logger.d("giftWrapEvent: ${giftWrapEvent.toJson()}")
database.nostrNip17Dao().persistAndBroadcastGiftWrap(
sealedRumorEvent = sealedRumorEvent,
@@ -146,6 +150,7 @@ class DatabaseChatRepository(
giftWrapSealId = sealedRumorEvent.id
)
)
logger.d("GiftWrap now sealed: ${giftWrapPayload.id}")
}
}
}