fix: cleanup warnings; centralise url creation into config

This commit is contained in:
nullishamy 2025-04-26 13:08:49 +01:00
parent 4b88100373
commit 9bc6c12392
Signed by: amy
SSH key fingerprint: SHA256:WmV0uk6WgAQvDJlM8Ld4mFPHZo02CLXXP5VkwQ5xtyk
11 changed files with 102 additions and 55 deletions

View file

@ -1,6 +1,6 @@
use std::sync::mpsc;
use std::thread;
use tracing::{debug, info, span, Level};
use tracing::{info, span, Level};
#[derive(Debug)]
pub enum QueueMessage {

View file

@ -9,3 +9,41 @@ pub struct ServerConfig {
pub struct Config {
pub server: ServerConfig,
}
impl Config {
pub fn host(&self) -> &str {
&self.server.host
}
pub fn user_url(&self, user_uuid: &str) -> String {
format!("{}/users/{}", self.host(), user_uuid)
}
pub fn user_web_url(&self, user_name: &str) -> String {
format!("{}/{}", self.host(), user_name)
}
pub fn followers_url(&self, user_uuid: &str) -> String {
format!("{}/followers", self.user_url(user_uuid))
}
pub fn following_url(&self, user_uuid: &str) -> String {
format!("{}/following", self.user_url(user_uuid))
}
pub fn inbox_url(&self, user_uuid: &str) -> String {
format!("{}/inbox", self.user_url(user_uuid))
}
pub fn outbox_url(&self, user_uuid: &str) -> String {
format!("{}/outbox", self.user_url(user_uuid))
}
pub fn post_url(&self, poster_uuid: &str, post_uuid: &str) -> String {
format!("{}/{}", self.user_url(poster_uuid), post_uuid)
}
pub fn activity_url(&self, activity_uuid: &str) -> String {
format!("{}/activities/{}", self.host(), activity_uuid)
}
}