Remove redundant relay.schema field
This commit is contained in:
+1
-1
@@ -72,7 +72,7 @@ All configuration is read from the environment by `Env::load()` at startup. **Ev
|
||||
| `LIVEKIT_API_KEY` | LiveKit API key sent to zooid |
|
||||
| `LIVEKIT_API_SECRET` | LiveKit API secret sent to zooid |
|
||||
|
||||
**Blossom S3** — sent to zooid as the S3 adapter config (with `key_prefix` = relay schema) when a relay enables blossom.
|
||||
**Blossom S3** — sent to zooid as the S3 adapter config (with `key_prefix` = relay id) when a relay enables blossom.
|
||||
|
||||
| Variable | Description |
|
||||
| ----------------------- | --------------------- |
|
||||
|
||||
@@ -20,7 +20,6 @@ CREATE TABLE IF NOT EXISTS tenant (
|
||||
CREATE TABLE IF NOT EXISTS relay (
|
||||
id TEXT PRIMARY KEY,
|
||||
tenant TEXT NOT NULL,
|
||||
schema TEXT NOT NULL,
|
||||
subdomain TEXT NOT NULL UNIQUE,
|
||||
plan TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ Handlers take `State<Arc<Api>>`, an optional `AuthedPubkey`, then path/query/bod
|
||||
## `create_relay` — `POST /relays`
|
||||
|
||||
- Admin or the `tenant` pubkey in the request body
|
||||
- Generates the relay `id`/`schema`, validates and normalizes the relay via `prepare_relay`, and creates it via `command.create_relay`
|
||||
- Generates the relay `id`, validates and normalizes the relay via `prepare_relay`, and creates it via `command.create_relay`
|
||||
- Duplicate subdomain → `422` `subdomain-exists`
|
||||
- `data` is the relay; HTTP `201`
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ Members:
|
||||
- A relay is "new" only if it has never completed a sync (`synced != 1` and no `complete_relay_sync` activity exists). New relays are created with `POST /relay/:id`; existing relays are updated with `PATCH /relay/:id`.
|
||||
- A freshly generated `secret` is included only for creation (`POST`), so updates don't rotate relay identity and we never store the secret.
|
||||
- The body carries relay configuration: `host` (= `subdomain.relay_domain`), `schema`, `inactive` (true when status is `inactive` or `delinquent`), `info` (name/icon/description/pubkey), `policy`, `groups`, `management`, `blossom`, `livekit`, `push`, and hard-coded `roles`.
|
||||
- When `blossom_enabled`, the blossom section uses `adapter: "s3"` with the `BLOSSOM_S3_*` settings and `s3.key_prefix` set to the relay's `schema`; otherwise it sends `{ "enabled": false }`.
|
||||
- When `blossom_enabled`, the blossom section uses `adapter: "s3"` with the `BLOSSOM_S3_*` settings and `s3.key_prefix` set to the relay's `id`; otherwise it sends `{ "enabled": false }`.
|
||||
- When `livekit_enabled`, the livekit section carries the `LIVEKIT_*` settings; otherwise `{ "enabled": false }`.
|
||||
|
||||
## `pub async fn list_relay_members(&self, relay_id: &str) -> Result<Vec<String>>`
|
||||
|
||||
@@ -66,7 +66,6 @@ A relay is a nostr relay owned by a `tenant` and hosted by the attached zooid in
|
||||
|
||||
- `id` - calculated based on `subdomain` (with `-` replaced by `_`) + `_` + 8 random hex chars
|
||||
- `tenant` - the tenant's pubkey
|
||||
- `schema` - the relay's db schema (read only, same as `id`)
|
||||
- `subdomain` - the relay's subdomain
|
||||
- `plan` - the relay's plan
|
||||
- `status` - one of `active|inactive|delinquent`. Only `active` relays count toward billing. `delinquent` is set by the billing system when a relay's subscription becomes past due; `inactive` is set when a user or admin manually deactivates a relay.
|
||||
|
||||
@@ -177,16 +177,15 @@ impl Command {
|
||||
self.with_activity("create_relay", "relay", &relay.id, async |tx| {
|
||||
sqlx::query(
|
||||
"INSERT INTO relay (
|
||||
id, tenant, schema, subdomain, plan, status, synced, sync_error,
|
||||
id, tenant, subdomain, plan, status, synced, sync_error,
|
||||
info_name, info_icon, info_description,
|
||||
policy_public_join, policy_strip_signatures,
|
||||
groups_enabled, management_enabled, blossom_enabled,
|
||||
livekit_enabled, push_enabled
|
||||
) VALUES (?, ?, ?, ?, ?, 'active', 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
) VALUES (?, ?, ?, ?, 'active', 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
)
|
||||
.bind(&relay.id)
|
||||
.bind(&relay.tenant)
|
||||
.bind(&relay.schema)
|
||||
.bind(&relay.subdomain)
|
||||
.bind(&relay.plan)
|
||||
.bind(&relay.sync_error)
|
||||
@@ -211,7 +210,7 @@ impl Command {
|
||||
self.with_activity("update_relay", "relay", &relay.id, async |tx| {
|
||||
sqlx::query(
|
||||
"UPDATE relay
|
||||
SET tenant = ?, schema = ?, subdomain = ?, plan = ?, status = ?, sync_error = ?, synced = 0,
|
||||
SET tenant = ?, subdomain = ?, plan = ?, status = ?, sync_error = ?, synced = 0,
|
||||
info_name = ?, info_icon = ?, info_description = ?,
|
||||
policy_public_join = ?, policy_strip_signatures = ?,
|
||||
groups_enabled = ?, management_enabled = ?, blossom_enabled = ?,
|
||||
@@ -219,7 +218,6 @@ impl Command {
|
||||
WHERE id = ?",
|
||||
)
|
||||
.bind(&relay.tenant)
|
||||
.bind(&relay.schema)
|
||||
.bind(&relay.subdomain)
|
||||
.bind(&relay.plan)
|
||||
.bind(&relay.status)
|
||||
|
||||
@@ -185,7 +185,7 @@ impl Infra {
|
||||
|
||||
let mut body = serde_json::json!({
|
||||
"host": format!("{}.{}", relay.subdomain, self.env.relay_domain),
|
||||
"schema": relay.schema,
|
||||
"schema": relay.id,
|
||||
"inactive": relay.status == RELAY_STATUS_INACTIVE
|
||||
|| relay.status == RELAY_STATUS_DELINQUENT,
|
||||
"info": {
|
||||
@@ -210,7 +210,7 @@ impl Infra {
|
||||
"bucket": self.env.blossom_s3_bucket,
|
||||
"access_key": self.env.blossom_s3_access_key,
|
||||
"secret_key": self.env.blossom_s3_secret_key,
|
||||
"key_prefix": relay.schema,
|
||||
"key_prefix": relay.id,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -52,7 +52,6 @@ pub struct LightningInvoice {
|
||||
pub struct Relay {
|
||||
pub id: String,
|
||||
pub tenant: String,
|
||||
pub schema: String,
|
||||
pub subdomain: String,
|
||||
pub plan: String,
|
||||
pub status: String,
|
||||
@@ -75,7 +74,6 @@ impl Default for Relay {
|
||||
Self {
|
||||
id: String::new(),
|
||||
tenant: String::new(),
|
||||
schema: String::new(),
|
||||
subdomain: String::new(),
|
||||
plan: String::new(),
|
||||
status: RELAY_STATUS_ACTIVE.to_string(),
|
||||
|
||||
@@ -114,7 +114,6 @@ pub async fn create_relay(
|
||||
let relay = Relay {
|
||||
id: relay_id.clone(),
|
||||
tenant: payload.tenant,
|
||||
schema: relay_id.clone(),
|
||||
subdomain: payload.subdomain,
|
||||
plan: payload.plan,
|
||||
info_name: payload.info_name,
|
||||
|
||||
@@ -46,7 +46,6 @@ export type PlanId = string
|
||||
export type Relay = {
|
||||
id: string
|
||||
tenant: string
|
||||
schema: string
|
||||
subdomain: string
|
||||
plan: PlanId
|
||||
status: string
|
||||
|
||||
Reference in New Issue
Block a user