[CHORE] flake8 issues E402, E721 and F821 (#1874)
* F821: undefine name disabled and logged webhook_listener for opennode and lnpay because they are obviously not working * E402: module level import not at top of file * E721 fixes, only popped up for python3.9 not 3.10
This commit is contained in:
+13
-14
@@ -1,10 +1,7 @@
|
||||
import asyncio
|
||||
import hmac
|
||||
from http import HTTPStatus
|
||||
from typing import AsyncGenerator, Optional
|
||||
|
||||
import httpx
|
||||
from fastapi import HTTPException
|
||||
from loguru import logger
|
||||
|
||||
from lnbits.settings import settings
|
||||
@@ -136,18 +133,20 @@ class OpenNodeWallet(Wallet):
|
||||
yield value
|
||||
|
||||
async def webhook_listener(self):
|
||||
logger.error("webhook listener for opennode is disabled.")
|
||||
return
|
||||
# TODO: request.form is undefined, was it something with Flask or quart?
|
||||
# probably issue introduced when refactoring?
|
||||
data = await request.form # type: ignore
|
||||
if "status" not in data or data["status"] != "paid":
|
||||
raise HTTPException(status_code=HTTPStatus.NO_CONTENT)
|
||||
# data = await request.form # type: ignore
|
||||
# if "status" not in data or data["status"] != "paid":
|
||||
# raise HTTPException(status_code=HTTPStatus.NO_CONTENT)
|
||||
|
||||
charge_id = data["id"]
|
||||
x = hmac.new(self.auth["Authorization"].encode("ascii"), digestmod="sha256")
|
||||
x.update(charge_id.encode("ascii"))
|
||||
if x.hexdigest() != data["hashed_order"]:
|
||||
logger.error("invalid webhook, not from opennode")
|
||||
raise HTTPException(status_code=HTTPStatus.NO_CONTENT)
|
||||
# charge_id = data["id"]
|
||||
# x = hmac.new(self.auth["Authorization"].encode("ascii"), digestmod="sha256")
|
||||
# x.update(charge_id.encode("ascii"))
|
||||
# if x.hexdigest() != data["hashed_order"]:
|
||||
# logger.error("invalid webhook, not from opennode")
|
||||
# raise HTTPException(status_code=HTTPStatus.NO_CONTENT)
|
||||
|
||||
await self.queue.put(charge_id)
|
||||
raise HTTPException(status_code=HTTPStatus.NO_CONTENT)
|
||||
# await self.queue.put(charge_id)
|
||||
# raise HTTPException(status_code=HTTPStatus.NO_CONTENT)
|
||||
|
||||
Reference in New Issue
Block a user