mirror of
https://github.com/nullishamy/ferri.git
synced 2025-06-28 17:14:18 +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,4 +1,6 @@
|
|||
use rocket::{get, serde::json::Json};
|
||||
use rocket::{get, serde::json::Json, State};
|
||||
|
||||
use crate::Config;
|
||||
|
||||
use crate::types::instance::{
|
||||
Accounts, Configuration, Contact, Instance, MediaAttachments, Polls, Registrations, Statuses,
|
||||
|
@ -6,9 +8,9 @@ use crate::types::instance::{
|
|||
};
|
||||
|
||||
#[get("/instance")]
|
||||
pub async fn instance() -> Json<Instance> {
|
||||
pub async fn instance(config: &State<Config>) -> Json<Instance> {
|
||||
Json(Instance {
|
||||
domain: "ferri.amy.mov".to_string(),
|
||||
domain: config.host().to_string(),
|
||||
title: "Ferri".to_string(),
|
||||
version: "0.0.1".to_string(),
|
||||
source_url: "https://forge.amy.mov/amy/ferri".to_string(),
|
||||
|
|
|
@ -26,11 +26,11 @@ pub struct StatusContext {
|
|||
descendants: Vec<Status>
|
||||
}
|
||||
|
||||
#[get("/statuses/<status>/context")]
|
||||
#[get("/statuses/<_status>/context")]
|
||||
pub async fn status_context(
|
||||
status: &str,
|
||||
user: AuthenticatedUser,
|
||||
mut db: Connection<Db>
|
||||
_status: &str,
|
||||
_user: AuthenticatedUser,
|
||||
_db: Connection<Db>
|
||||
) -> Json<StatusContext> {
|
||||
Json(StatusContext {
|
||||
ancestors: vec![],
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -95,7 +95,7 @@ pub async fn new_follow(
|
|||
pub async fn account(
|
||||
mut db: Connection<Db>,
|
||||
uuid: &str,
|
||||
user: AuthenticatedUser,
|
||||
_user: AuthenticatedUser,
|
||||
) -> Result<Json<TimelineAccount>, NotFound<String>> {
|
||||
let user = ap::User::from_id(uuid, &mut **db)
|
||||
.await
|
||||
|
@ -123,12 +123,12 @@ pub async fn account(
|
|||
}))
|
||||
}
|
||||
|
||||
#[get("/accounts/<uuid>/statuses?<limit>")]
|
||||
#[get("/accounts/<uuid>/statuses?<_limit>")]
|
||||
pub async fn statuses(
|
||||
mut db: Connection<Db>,
|
||||
uuid: &str,
|
||||
limit: Option<i64>,
|
||||
user: AuthenticatedUser,
|
||||
_limit: Option<i64>,
|
||||
_user: AuthenticatedUser,
|
||||
) -> Result<Json<Vec<TimelineStatus>>, NotFound<String>> {
|
||||
let user = ap::User::from_id(uuid, &mut **db)
|
||||
.await
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue