mirror of
https://github.com/nullishamy/ferri.git
synced 2025-06-28 00:54:17 +00:00
fix: cleanup warnings; centralise url creation into config
This commit is contained in:
parent
4b88100373
commit
9bc6c12392
11 changed files with 102 additions and 55 deletions
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue