From 7750a5e552074721ea01c3b95b47335e480bb091 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 16 Jun 2026 09:04:17 -0700 Subject: [PATCH] Put host in the relay stuct --- backend/src/infra.rs | 6 +----- backend/src/models.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/backend/src/infra.rs b/backend/src/infra.rs index ecd5c3d..ff375a0 100644 --- a/backend/src/infra.rs +++ b/backend/src/infra.rs @@ -281,11 +281,7 @@ async fn try_sync_relay(relay: &Relay) -> Result<()> { .await? .is_none(); - let host = if relay.custom_domain_verified == 1 && !relay.custom_domain.is_empty() { - relay.custom_domain.clone() - } else { - format!("{}.{}", relay.subdomain, env::get().relay_domain) - }; + let host = relay.host(); let mut body = serde_json::json!({ "host": host, diff --git a/backend/src/models.rs b/backend/src/models.rs index 18bb64b..a451a9b 100644 --- a/backend/src/models.rs +++ b/backend/src/models.rs @@ -96,6 +96,18 @@ pub struct Relay { pub created_at: i64, } +impl Relay { + /// The relay's effective public host: its verified custom domain when set, + /// otherwise its canonical `.`. + pub fn host(&self) -> String { + if self.custom_domain_verified == 1 && !self.custom_domain.is_empty() { + self.custom_domain.clone() + } else { + format!("{}.{}", self.subdomain, crate::env::get().relay_domain) + } + } +} + impl Default for Relay { fn default() -> Self { Self {