feat: config basics; fmt; small issues

Closes #11
This commit is contained in:
nullishamy 2025-04-23 19:13:03 +01:00
parent 918dcb60f9
commit 005c13e1d4
Signed by: amy
SSH key fingerprint: SHA256:WmV0uk6WgAQvDJlM8Ld4mFPHZo02CLXXP5VkwQ5xtyk
9 changed files with 43 additions and 14 deletions

View file

@ -76,10 +76,7 @@ pub async fn new_follow(
};
let req = ap::OutgoingActivity {
signed_by: format!(
"https://ferri.amy.mov/users/{}#main-key",
follower.username()
),
signed_by: format!("{}#main-key", follower.uri()),
req: activity,
to: followed.actor().clone(),
};

View file

@ -36,7 +36,7 @@ pub async fn finger_account(mut db: Connection<Db>, account: &str) -> status::Ac
r#"
INSERT INTO user (id, username, actor_id, display_name)
VALUES (?1, ?2, ?3, ?4)
ON CONFLICT(id) DO NOTHING
ON CONFLICT(actor_id) DO NOTHING
"#,
uuid,
username,
@ -47,7 +47,7 @@ pub async fn finger_account(mut db: Connection<Db>, account: &str) -> status::Ac
.await
.unwrap();
status::Accepted(format!("https://ferri.amy.mov/users/{}", username))
status::Accepted(format!("https://ferri.amy.mov/users/{}", uuid))
}
pub async fn resolve_user(acct: &str, host: &str) -> types::Person {

View file

@ -3,6 +3,7 @@ use endpoints::{
custom, inbox, oauth, user, well_known,
};
use main::ap::http;
use main::config::Config;
use rocket::{
Build, Request, Rocket, build, get,
http::ContentType,
@ -20,7 +21,8 @@ mod types;
pub struct Db(sqlx::SqlitePool);
#[get("/")]
async fn user_profile() -> (ContentType, &'static str) {
async fn user_profile(cfg: &rocket::State<Config>) -> (ContentType, &'static str) {
dbg!(cfg);
(ContentType::HTML, "<p>hello</p>")
}
@ -58,9 +60,10 @@ impl<'a> FromRequest<'a> for AuthenticatedUser {
}
}
pub fn launch() -> Rocket<Build> {
pub fn launch(cfg: Config) -> Rocket<Build> {
let http_client = http::HttpClient::new();
build()
.manage(cfg)
.manage(http_client)
.attach(Db::init())
.attach(cors::CORS)