mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-03-17 13:21:48 +01:00
better hints for subscription service
This commit is contained in:
parent
d53450b68f
commit
6b1ee91c8d
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user