From 7e860e65fdd12ec20f67cad7554ab0c3c17ac7dd Mon Sep 17 00:00:00 2001 From: koalasat Date: Tue, 29 Jul 2025 17:06:19 +0200 Subject: [PATCH 1/2] Add random expiration to notifications --- api/nostr.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/api/nostr.py b/api/nostr.py index 0efa222c..45726952 100644 --- a/api/nostr.py +++ b/api/nostr.py @@ -1,6 +1,8 @@ import pygeohash import hashlib import uuid +import random +from datetime import datetime, timedelta from secp256k1 import PrivateKey from asgiref.sync import sync_to_async @@ -57,6 +59,22 @@ class Nostr: ] ), 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) @@ -118,7 +136,17 @@ class Nostr: Tag.parse( [ "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), ] ), From ef44d41a3879a736bb5a7986a0fcd48bb0944f03 Mon Sep 17 00:00:00 2001 From: koalasat Date: Tue, 29 Jul 2025 17:07:18 +0200 Subject: [PATCH 2/2] Revert order --- api/nostr.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/api/nostr.py b/api/nostr.py index 45726952..9b96ab6c 100644 --- a/api/nostr.py +++ b/api/nostr.py @@ -136,17 +136,7 @@ class Nostr: Tag.parse( [ "expiration", - str( - int( - ( - datetime.now() - + timedelta(days=14) - + timedelta( - seconds=random.randint(0, 14 * 24 * 60 * 60) - ) - ).timestamp() - ) - ), + str(int(order.expires_at.timestamp())), str(order.escrow_duration), ] ),