From dc50d3493dd3132b642b86a4d205fb413c3d861d Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Thu, 6 Apr 2023 18:14:12 +0300 Subject: [PATCH] fix: is free to join if `cost_to_join == 0` --- relay/event_validator.py | 2 +- relay/relay.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/relay/event_validator.py b/relay/event_validator.py index 3b620bf..0975588 100644 --- a/relay/event_validator.py +++ b/relay/event_validator.py @@ -90,7 +90,7 @@ class EventValidator: f"Public key '{pubkey}' is not allowed in relay '{self.relay_id}'!", ) - if not account.can_join and self.config.is_paid_relay: + if not account.can_join and not self.config.is_free_to_join: return False, f"This is a paid relay: '{self.relay_id}'" stored_bytes = await get_storage_for_public_key(self.relay_id, pubkey) diff --git a/relay/relay.py b/relay/relay.py index 82320f9..51043e2 100644 --- a/relay/relay.py +++ b/relay/relay.py @@ -79,6 +79,10 @@ class PaymentSpec(Spec): storage_cost_value = Field(0, alias="storageCostValue") storage_cost_unit = Field("MB", alias="storageCostUnit") + @property + def is_free_to_join(self): + return not self.is_paid_relay or self.cost_to_join == 0 + class WalletSpec(Spec): wallet = Field("")