fix: publish events via websocket
This commit is contained in:
parent
f978d9e97f
commit
9931a08566
3 changed files with 6 additions and 38 deletions
|
|
@ -1,28 +1,18 @@
|
|||
from threading import Thread
|
||||
from typing import Callable
|
||||
|
||||
import httpx
|
||||
from loguru import logger
|
||||
from websocket import WebSocketApp
|
||||
|
||||
from lnbits.app import settings
|
||||
from lnbits.helpers import url_for
|
||||
|
||||
from .. import send_req_queue
|
||||
from .event import NostrEvent
|
||||
|
||||
|
||||
async def publish_nostr_event(e: NostrEvent):
|
||||
url = url_for("/nostrclient/api/v1/publish", external=True)
|
||||
data = dict(e)
|
||||
print("### published", dict(data))
|
||||
async with httpx.AsyncClient() as client:
|
||||
try:
|
||||
await client.post(
|
||||
url,
|
||||
json=data,
|
||||
)
|
||||
except Exception as ex:
|
||||
logger.warning(ex)
|
||||
print('### publish_nostr_event', e.dict())
|
||||
await send_req_queue.put(["EVENT", e.dict()])
|
||||
|
||||
|
||||
async def connect_to_nostrclient_ws(
|
||||
|
|
@ -44,23 +34,3 @@ async def connect_to_nostrclient_ws(
|
|||
wst.start()
|
||||
|
||||
return ws
|
||||
|
||||
|
||||
# async def handle_event(event, pubkeys):
|
||||
# tags = [t[1] for t in event["tags"] if t[0] == "p"]
|
||||
# to_merchant = None
|
||||
# if tags and len(tags) > 0:
|
||||
# to_merchant = tags[0]
|
||||
|
||||
# if event["pubkey"] in pubkeys or to_merchant in pubkeys:
|
||||
# logger.debug(f"Event sent to {to_merchant}")
|
||||
# pubkey = to_merchant if to_merchant in pubkeys else event["pubkey"]
|
||||
# # Send event to market extension
|
||||
# await send_event_to_market(event=event, pubkey=pubkey)
|
||||
|
||||
|
||||
# async def send_event_to_market(event: dict, pubkey: str):
|
||||
# # Sends event to market extension, for decrypt and handling
|
||||
# market_url = url_for(f"/market/api/v1/nip04/{pubkey}", external=True)
|
||||
# async with httpx.AsyncClient() as client:
|
||||
# await client.post(url=market_url, json=event)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue