Add random expiration to notifications

This commit is contained in:
koalasat
2025-07-29 17:06:19 +02:00
parent 44354cd362
commit 7e860e65fd

View File

@ -1,6 +1,8 @@
import pygeohash import pygeohash
import hashlib import hashlib
import uuid import uuid
import random
from datetime import datetime, timedelta
from secp256k1 import PrivateKey from secp256k1 import PrivateKey
from asgiref.sync import sync_to_async from asgiref.sync import sync_to_async
@ -57,6 +59,22 @@ class Nostr:
] ]
), ),
Tag.parse(["status", str(order.status)]), Tag.parse(["status", str(order.status)]),
Tag.parse(
[
"expiration",
str(
int(
(
datetime.now()
+ timedelta(days=14)
+ timedelta(
seconds=random.randint(0, 14 * 24 * 60 * 60)
)
).timestamp()
)
),
]
),
] ]
await client.send_private_msg(PublicKey.parse(robot.nostr_pubkey), text, tags) await client.send_private_msg(PublicKey.parse(robot.nostr_pubkey), text, tags)
@ -118,7 +136,17 @@ class Nostr:
Tag.parse( Tag.parse(
[ [
"expiration", "expiration",
str(int(order.expires_at.timestamp())), str(
int(
(
datetime.now()
+ timedelta(days=14)
+ timedelta(
seconds=random.randint(0, 14 * 24 * 60 * 60)
)
).timestamp()
)
),
str(order.escrow_duration), str(order.escrow_duration),
] ]
), ),