Fixes giftwrap date mismatch

This commit is contained in:
Vitor Pamplona 2024-06-17 16:20:40 -04:00
parent aad95595eb
commit 0fa6dce42c
3 changed files with 6 additions and 12 deletions

View File

@ -56,9 +56,7 @@ class GiftWrapEvent(
override fun isContentEncoded() = true
fun preCachedGift(signer: NostrSigner): Event? {
return cachedInnerEvent[signer.pubKey]
}
fun preCachedGift(signer: NostrSigner): Event? = cachedInnerEvent[signer.pubKey]
fun addToCache(
pubKey: HexKey,
@ -114,7 +112,7 @@ class GiftWrapEvent(
fun create(
event: Event,
recipientPubKey: HexKey,
createdAt: Long = TimeUtils.randomWithinAWeek(),
createdAt: Long = TimeUtils.randomWithTwoDays(),
onReady: (GiftWrapEvent) -> Unit,
) {
val signer = NostrSignerInternal(KeyPair()) // GiftWrap is always a random key

View File

@ -58,9 +58,7 @@ class SealedGossipEvent(
override fun isContentEncoded() = true
fun preCachedGossip(signer: NostrSigner): Event? {
return cachedInnerEvent[signer.pubKey]
}
fun preCachedGossip(signer: NostrSigner): Event? = cachedInnerEvent[signer.pubKey]
fun addToCache(
pubKey: HexKey,
@ -133,7 +131,7 @@ class SealedGossipEvent(
gossip: Gossip,
encryptTo: HexKey,
signer: NostrSigner,
createdAt: Long = TimeUtils.randomWithinAWeek(),
createdAt: Long = TimeUtils.randomWithTwoDays(),
onReady: (SealedGossipEvent) -> Unit,
) {
val msg = Gossip.toJson(gossip)
@ -172,8 +170,6 @@ class Gossip(
fun toJson(event: Gossip): String = Event.mapper.writeValueAsString(event)
fun create(event: Event): Gossip {
return Gossip(event.id, event.pubKey, event.createdAt, event.kind, event.tags, event.content)
}
fun create(event: Event): Gossip = Gossip(event.id, event.pubKey, event.createdAt, event.kind, event.tags, event.content)
}
}

View File

@ -55,5 +55,5 @@ object TimeUtils {
fun oneWeekAgo() = now() - ONE_WEEK
fun randomWithinAWeek() = System.currentTimeMillis() / 1000 - CryptoUtils.randomInt(ONE_WEEK)
fun randomWithTwoDays() = System.currentTimeMillis() / 1000 - CryptoUtils.randomInt(twoDays())
}