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,5 +1,6 @@
use crate::{AuthenticatedUser, Db, endpoints::api::user::CredentialAcount};
use crate::{AuthenticatedUser, Db, endpoints::api::user::CredentialAcount, Config};
use rocket::{
State,
get,
serde::{Deserialize, Serialize, json::Json},
};
@ -32,11 +33,12 @@ pub struct TimelineStatus {
pub account: TimelineAccount,
}
#[get("/timelines/home?<limit>")]
#[get("/timelines/home?<_limit>")]
pub async fn home(
mut db: Connection<Db>,
limit: i64,
user: AuthenticatedUser,
config: &State<Config>,
_limit: i64,
_user: AuthenticatedUser,
) -> Json<Vec<TimelineStatus>> {
let posts = sqlx::query!(
r#"
@ -66,7 +68,7 @@ pub async fn home(
.await
.unwrap();
let user_uri = format!("https://ferri.amy.mov/users/{}", record.user_id);
let user_uri = config.user_url(&record.user_id);
boost = Some(Box::new(TimelineStatus {
id: record.post_id.clone(),
created_at: record.created_at.clone(),
@ -110,7 +112,7 @@ pub async fn home(
}))
}
let user_uri = format!("https://ferri.amy.mov/users/{}", record.username);
let user_uri = config.user_web_url(&record.username);
out.push(TimelineStatus {
id: record.post_id.clone(),
created_at: record.created_at.clone(),