diff --git a/nostr_dvm/dvm.py b/nostr_dvm/dvm.py index 6a579d1..f4b7429 100644 --- a/nostr_dvm/dvm.py +++ b/nostr_dvm/dvm.py @@ -142,12 +142,15 @@ class DVM: if int(user.subscribed) > int(Timestamp.now().as_secs()): print("User subscribed until: " + str(Timestamp.from_secs(user.subscribed).to_human_datetime())) user_has_active_subscription = True - await send_job_status_reaction(nip90_event, "subscription-required", True, amount, + await send_job_status_reaction(nip90_event, "subscription-active", True, amount, self.client, "User subscripton active until " + Timestamp.from_secs( int(user.subscribed)).to_human_datetime().replace( "Z", " ").replace("T", " ") + " GMT", self.dvm_config) - # otherwise we check for an active subscription by checking recipie events + # otherwise we check for an active subscription by checking recipie events + # sleep a little to not get rate limited + await asyncio.sleep(0.5) + else: print("[" + self.dvm_config.NIP89.NAME + "] Checking Subscription status") #await send_job_status_reaction(nip90_event, "subscription-required", True, amount, self.client, @@ -168,12 +171,18 @@ class DVM: " ").replace( "T", " ") + " GMT", self.dvm_config) + + print("Checked Recipe: User subscribed until: " + str( Timestamp.from_secs(int(subscription_status["validUntil"])).to_human_datetime())) user_has_active_subscription = True update_user_subscription(user.npub, int(subscription_status["validUntil"]), self.client, self.dvm_config) + + #sleep a little before sending next status update + + else: print("No active subscription found") await send_job_status_reaction(nip90_event, "subscription-required", True, amount, diff --git a/nostr_dvm/utils/output_utils.py b/nostr_dvm/utils/output_utils.py index 5e327ae..fd53506 100644 --- a/nostr_dvm/utils/output_utils.py +++ b/nostr_dvm/utils/output_utils.py @@ -268,6 +268,15 @@ def build_status_reaction(status, task, amount, content, dvm_config): alt_description = "NIP90 DVM task " + task + " requires payment for subscription" reaction = alt_description + emoji.emojize(":orange_heart:") + elif status == "subscription-active": + if content is not None and content != "": + alt_description = content + reaction = alt_description + + else: + alt_description = "NIP90 DVM task " + task + " has active subscription" + reaction = alt_description + emoji.emojize(":orange_heart:") + elif status == "payment-rejected": diff --git a/setup.py b/setup.py index d45da4d..8def08a 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -VERSION = '0.7.3' +VERSION = '0.7.4' DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines' LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. See the github repository for more information') diff --git a/tests/discovery.py b/tests/discovery.py index 3ae9739..6ad2372 100644 --- a/tests/discovery.py +++ b/tests/discovery.py @@ -675,7 +675,7 @@ def playground(): update_db = False options_nonfollowers_popular = { "db_name": "db/nostr_recent_notes.db", - "db_since": 12 * 60 * 60, # 2h since gmt, + "db_since": 3 * 60 * 60, # 2h since gmt, } cost = 0 image = "https://i.nostr.build/l11EczDmpZBaxlRm.jpg" diff --git a/ui/noogle/src/components/RecommendationGeneration.vue b/ui/noogle/src/components/RecommendationGeneration.vue index 5e92fff..e9648ff 100644 --- a/ui/noogle/src/components/RecommendationGeneration.vue +++ b/ui/noogle/src/components/RecommendationGeneration.vue @@ -305,7 +305,7 @@ async function listen() { for (const tag in event.tags) { if (event.tags[tag].asVec()[0] === "status") { - if (event.content !== "" && (event.tags[tag].asVec()[1] === "processing" || event.tags[tag].asVec()[1] === "subscription-required" ) ) { + if (event.content !== "" && (event.tags[tag].asVec()[1] === "processing" || event.tags[tag].asVec()[1] === "subscription-required" || event.tags[tag].asVec()[1] === "subscription-active" ) ) { if(event.tags[tag].asVec().length > 2) { dvms.find(i => i.id === event.author.toHex()).status = event.tags[tag].asVec()[2] } @@ -1026,7 +1026,7 @@ const submitHandler = async () => {
- +
-

+

{{dvm.amount/1000}}