Conflate id and schema
This commit is contained in:
@@ -63,9 +63,9 @@ Tenants are customers of the service, identified by a nostr `pubkey`. Public met
|
|||||||
|
|
||||||
A relay is a nostr relay owned by a `tenant` and hosted by the attached zooid instance. Relay subdomains MUST be unique.
|
A relay is a nostr relay owned by a `tenant` and hosted by the attached zooid instance. Relay subdomains MUST be unique.
|
||||||
|
|
||||||
- `id` - a random ID identifying the relay
|
- `id` - calculated based on `subdomain` + 8 random hex chars
|
||||||
- `tenant` - the tenant's pubkey
|
- `tenant` - the tenant's pubkey
|
||||||
- `schema` - the relay's db schema (read_only, calculated based on `subdomain` + `id`)
|
- `schema` - the relay's db schema (read only, same as `id`)
|
||||||
- `subdomain` - the relay's subdomain
|
- `subdomain` - the relay's subdomain
|
||||||
- `plan` - the relay's plan
|
- `plan` - the relay's plan
|
||||||
- `stripe_subscription_item_id` (nullable) - the Stripe subscription item id. Only set for relays on paid plans.
|
- `stripe_subscription_item_id` (nullable) - the Stripe subscription item id. Only set for relays on paid plans.
|
||||||
|
|||||||
+8
-5
@@ -275,9 +275,6 @@ impl Api {
|
|||||||
return Err(RelayValidationError::PremiumFeature);
|
return Err(RelayValidationError::PremiumFeature);
|
||||||
}
|
}
|
||||||
|
|
||||||
if relay.schema.is_empty() {
|
|
||||||
relay.schema = format!("{}_{}", relay.subdomain.replace('-', "_"), relay.id);
|
|
||||||
}
|
|
||||||
if relay.status.is_empty() {
|
if relay.status.is_empty() {
|
||||||
relay.status = RELAY_STATUS_ACTIVE.to_string();
|
relay.status = RELAY_STATUS_ACTIVE.to_string();
|
||||||
}
|
}
|
||||||
@@ -754,10 +751,16 @@ async fn create_relay(
|
|||||||
let auth = state.api.extract_auth_pubkey(&headers)?;
|
let auth = state.api.extract_auth_pubkey(&headers)?;
|
||||||
state.api.require_admin_or_tenant(&auth, &payload.tenant)?;
|
state.api.require_admin_or_tenant(&auth, &payload.tenant)?;
|
||||||
|
|
||||||
|
let relay_id = format!(
|
||||||
|
"{}_{}",
|
||||||
|
payload.subdomain.replace('-', "_"),
|
||||||
|
&uuid::Uuid::new_v4().simple().to_string()[..8]
|
||||||
|
);
|
||||||
|
|
||||||
let mut relay = Relay {
|
let mut relay = Relay {
|
||||||
id: uuid::Uuid::new_v4().to_string(),
|
id: relay_id.clone(),
|
||||||
tenant: payload.tenant,
|
tenant: payload.tenant,
|
||||||
schema: String::new(),
|
schema: relay_id.clone(),
|
||||||
subdomain: payload.subdomain,
|
subdomain: payload.subdomain,
|
||||||
plan: payload.plan,
|
plan: payload.plan,
|
||||||
stripe_subscription_item_id: None,
|
stripe_subscription_item_id: None,
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ dev:
|
|||||||
cd frontend && bun dev &
|
cd frontend && bun dev &
|
||||||
wait
|
wait
|
||||||
|
|
||||||
|
dev-backend:
|
||||||
|
cd backend && onchange src -ik -- bash -c 'RUST_LOG=backend=info cargo run'
|
||||||
|
|
||||||
dev-frontend:
|
dev-frontend:
|
||||||
cd frontend && bun run dev
|
cd frontend && bun run dev
|
||||||
|
|
||||||
@@ -27,7 +30,7 @@ build-backend:
|
|||||||
cd backend && cargo build
|
cd backend && cargo build
|
||||||
|
|
||||||
build-frontend:
|
build-frontend:
|
||||||
cd frontend && bun run build
|
cd frontend && bun i && bun run build
|
||||||
|
|
||||||
fmt: fmt-backend
|
fmt: fmt-backend
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user