diff --git a/models.py b/models.py index 355128a..29d91e9 100644 --- a/models.py +++ b/models.py @@ -40,6 +40,7 @@ class MerchantProfile(BaseModel): class MerchantConfig(MerchantProfile): event_id: Optional[str] + sync_from_nostr = False class PartialMerchant(BaseModel): diff --git a/nostr/nostr_client.py b/nostr/nostr_client.py index 6a29d2c..a2a936c 100644 --- a/nostr/nostr_client.py +++ b/nostr/nostr_client.py @@ -81,10 +81,25 @@ class NostrClient: ["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): 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}"]) + 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): try: self.ws.close()