Fix: tasks.py reuse db connection for invoice deletion (#971)

* check if wallet exists

* check wallet existence in key check

* reuse db connection for payment deletion
This commit is contained in:
calle 2022-09-15 14:48:59 +03:00 committed by GitHub
parent 6f9ad06449
commit 232d50baaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -174,7 +174,7 @@ class Payment(BaseModel):
logger.warning(
f"Deleting outgoing failed payment {self.checking_id}: {status}"
)
await self.delete()
await self.delete(conn)
elif not status.pending:
logger.info(
f"Marking '{'in' if self.is_in else 'out'}' {self.checking_id} as not pending anymore: {status}"
@ -182,10 +182,10 @@ class Payment(BaseModel):
await self.update_status(status, conn=conn)
return status
async def delete(self) -> None:
async def delete(self, conn: Optional[Connection] = None) -> None:
from .crud import delete_payment
await delete_payment(self.checking_id)
await delete_payment(self.checking_id, conn=conn)
class BalanceCheck(BaseModel):