fix
This commit is contained in:
@@ -344,6 +344,18 @@ class PaymentStorage:
|
||||
payments.pop(payment_id, None)
|
||||
await asyncio.to_thread(self._save_sync, payments)
|
||||
|
||||
async def pop(self, payment_id: str) -> Optional[dict]:
|
||||
"""Get and mark payment as processed. Returns None if not found or already processed."""
|
||||
async with self._lock:
|
||||
payments = await asyncio.to_thread(self._load_sync)
|
||||
data = payments.get(payment_id)
|
||||
if data is None or data.get("processed"):
|
||||
return None
|
||||
payments[payment_id]["processed"] = True
|
||||
payments[payment_id]["processed_at"] = datetime.now().isoformat(timespec="seconds")
|
||||
await asyncio.to_thread(self._save_sync, payments)
|
||||
return data
|
||||
|
||||
async def get_by_user(self, user_id: int) -> Optional[dict]:
|
||||
async with self._lock:
|
||||
payments = await asyncio.to_thread(self._load_sync)
|
||||
|
||||
Reference in New Issue
Block a user