mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-29 08:20:51 +00:00
Fixes giftwrap date mismatch
This commit is contained in:
parent
aad95595eb
commit
0fa6dce42c
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user