diff --git a/nostr_dvm/dvm.py b/nostr_dvm/dvm.py index a310fb2..b8ab756 100644 --- a/nostr_dvm/dvm.py +++ b/nostr_dvm/dvm.py @@ -164,7 +164,7 @@ class DVM: else: print("No active subscription found") send_job_status_reaction(nip90_event, "subscription-required", True, amount, self.client, - "No active subscription found..", + "No active subscription found. Manage your subscription at: " + self.dvm_config.SUBSCRIPTION_MANAGEMENT, self.dvm_config) for dvm in self.dvm_config.SUPPORTED_DVMS: diff --git a/nostr_dvm/subscription.py b/nostr_dvm/subscription.py index 6fca147..3268c5a 100644 --- a/nostr_dvm/subscription.py +++ b/nostr_dvm/subscription.py @@ -56,11 +56,17 @@ class Subscription: cancel_subscription_filter = Filter().kinds([EventDefinitions.KIND_NIP88_STOP_SUBSCRIPTION_EVENT]).since( Timestamp.now()) authors = [] - if admin_config is not None: + if admin_config is not None and len(admin_config.USERNPUBS) > 0: + #we might want to limit which services can connect to the subscription handler for key in admin_config.USERNPUBS: authors.append(PublicKey.parse(key)) - dvm_filter = Filter().authors(authors).pubkey(pk).kinds([EventDefinitions.KIND_NIP90_DVM_SUBSCRIPTION]).since( - Timestamp.now()) + dvm_filter = Filter().authors(authors).pubkey(pk).kinds([EventDefinitions.KIND_NIP90_DVM_SUBSCRIPTION]).since( + Timestamp.now()) + else: + # or we don't + dvm_filter = Filter().pubkey(pk).kinds( + [EventDefinitions.KIND_NIP90_DVM_SUBSCRIPTION]).since( + Timestamp.now()) self.client.subscribe([zap_filter, dvm_filter, cancel_subscription_filter], None) @@ -333,7 +339,7 @@ class Subscription: keys = Keys.parse(dvm_config.PRIVATE_KEY) message = ("Subscribed to DVM " + tier + ". Renewing on: " + str( - Timestamp.from_secs(end).to_human_datetime().replace("Z", " ").replace("T", " "))) + Timestamp.from_secs(end).to_human_datetime().replace("Z", " ").replace("T", " ") + " GMT")) evt = EventBuilder.encrypted_direct_msg(keys, PublicKey.parse(subscriber), message, None).to_event(keys) send_event(evt, client=self.client, dvm_config=dvm_config) diff --git a/nostr_dvm/utils/dvmconfig.py b/nostr_dvm/utils/dvmconfig.py index 31c2fc7..eb59386 100644 --- a/nostr_dvm/utils/dvmconfig.py +++ b/nostr_dvm/utils/dvmconfig.py @@ -32,6 +32,7 @@ class DVMConfig: USE_OWN_VENV = True # Make an own venv for each dvm's process function.Disable if you want to install packages into main venv. Only recommended if you dont want to run dvms with different dependency versions DB: str NEW_USER_BALANCE: int = 0 # Free credits for new users + SUBSCRIPTION_MANAGEMENT = 'https://noogle.lol/discovery' NIP88: NIP88Config NIP89: NIP89Config SEND_FEEDBACK_EVENTS = True diff --git a/tests/discovery.py b/tests/discovery.py index e66af70..17a2358 100644 --- a/tests/discovery.py +++ b/tests/discovery.py @@ -42,7 +42,7 @@ def playground(): subscription_config.LNBITS_ADMIN_KEY = admin_key # The dvm might pay failed jobs back subscription_config.LNBITS_URL = os.getenv("LNBITS_HOST") sub_admin_config = AdminConfig() - sub_admin_config.USERNPUBS = ["7782f93c5762538e1f7ccc5af83cd8018a528b9cd965048386ca1b75335f24c6"] #Add npubs of services that can contact the subscription handler + #sub_admin_config.USERNPUBS = ["7782f93c5762538e1f7ccc5af83cd8018a528b9cd965048386ca1b75335f24c6"] #Add npubs of services that can contact the subscription handler x = threading.Thread(target=Subscription, args=(Subscription(subscription_config, sub_admin_config),)) x.start()