feat: stubs for sync from nostr

This commit is contained in:
Vlad Stan 2023-03-24 15:10:30 +02:00
parent 13150f6360
commit c6bca39df8
2 changed files with 16 additions and 0 deletions

View file

@ -40,6 +40,7 @@ class MerchantProfile(BaseModel):
class MerchantConfig(MerchantProfile): class MerchantConfig(MerchantProfile):
event_id: Optional[str] event_id: Optional[str]
sync_from_nostr = False
class PartialMerchant(BaseModel): class PartialMerchant(BaseModel):

View file

@ -81,10 +81,25 @@ class NostrClient:
["REQ", f"direct-messages-out:{public_key}", out_messages_filter] ["REQ", f"direct-messages-out:{public_key}", out_messages_filter]
) )
async def subscribe_to_merchant_events(self, public_key: str, since: int):
stall_filter = {"kind": 30017, "authors": [public_key]}
product_filter = {"kind": 30018, "authors": [public_key]}
await self.send_req_queue.put(
["REQ", f"stall-events:{public_key}", stall_filter]
)
await self.send_req_queue.put(
["REQ", f"product-events:{public_key}", product_filter]
)
async def unsubscribe_from_direct_messages(self, public_key: str): async def unsubscribe_from_direct_messages(self, public_key: str):
await self.send_req_queue.put(["CLOSE", f"direct-messages-in:{public_key}"]) await self.send_req_queue.put(["CLOSE", f"direct-messages-in:{public_key}"])
await self.send_req_queue.put(["CLOSE", f"direct-messages-out:{public_key}"]) await self.send_req_queue.put(["CLOSE", f"direct-messages-out:{public_key}"])
async def unsubscribe_from_merchant_events(self, public_key: str):
await self.send_req_queue.put(["CLOSE", f"stall-events:{public_key}"])
await self.send_req_queue.put(["CLOSE", f"product-events:{public_key}"])
def stop(self): def stop(self):
try: try:
self.ws.close() self.ws.close()