From 7751114bda6bb2747108344ebb1a5d321d46262a Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 22 Mar 2024 01:56:06 +0100 Subject: [PATCH] fix: disable shared inbox/outbox they aren't really implemented anyway and it's too much hassle now, they're only relevant for big instances, not 1-user dev junk --- src/activitypub/mod.rs | 35 ++++------------------------------- src/server.rs | 5 +++-- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/src/activitypub/mod.rs b/src/activitypub/mod.rs index 82251526..438ef785 100644 --- a/src/activitypub/mod.rs +++ b/src/activitypub/mod.rs @@ -47,41 +47,14 @@ pub async fn view(State(ctx): State) -> Result, .set_id(Some(&url!(ctx, ""))) .set_name(Some("μpub")) .set_summary(Some("micro social network, federated")) - .set_inbox(Node::link(url!(ctx, "/inbox"))) - .set_outbox(Node::link(url!(ctx, "/outbox"))) + // .set_inbox(Node::link(url!(ctx, "/inbox"))) + // .set_outbox(Node::link(url!(ctx, "/outbox"))) .ld_context() )) } -pub async fn inbox(State(ctx) : State, Json(object): Json) -> Result, StatusCode> { - match object.base_type() { - None => { Err(StatusCode::BAD_REQUEST) }, - Some(BaseType::Link(_x)) => Err(StatusCode::UNPROCESSABLE_ENTITY), // we could but not yet - Some(BaseType::Object(ObjectType::Activity(ActivityType::Activity))) => Err(StatusCode::UNPROCESSABLE_ENTITY), - Some(BaseType::Object(ObjectType::Activity(ActivityType::Follow))) => { todo!() }, - Some(BaseType::Object(ObjectType::Activity(ActivityType::Like))) => { todo!() }, - Some(BaseType::Object(ObjectType::Activity(ActivityType::Create))) => { - let Ok(activity_entity) = model::activity::Model::new(&object) else { - return Err(StatusCode::UNPROCESSABLE_ENTITY); - }; - let Node::Object(obj) = object.object() else { - // TODO we could process non-embedded activities or arrays but im lazy rn - return Err(StatusCode::UNPROCESSABLE_ENTITY); - }; - let Ok(obj_entity) = model::object::Model::new(&*obj) else { - return Err(StatusCode::UNPROCESSABLE_ENTITY); - }; - model::object::Entity::insert(obj_entity.into_active_model()) - .exec(ctx.db()) - .await.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; - model::activity::Entity::insert(activity_entity.into_active_model()) - .exec(ctx.db()) - .await.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; - Ok(JsonLD(serde_json::Value::Null)) // TODO hmmmmmmmmmmm not the best value to return.... - }, - Some(BaseType::Object(ObjectType::Activity(_x))) => { Err(StatusCode::NOT_IMPLEMENTED) }, - Some(_x) => { Err(StatusCode::UNPROCESSABLE_ENTITY) } - } +pub async fn inbox(State(_ctx) : State, Json(_object): Json) -> Result, StatusCode> { + todo!() } pub async fn outbox(State(_db): State) -> Result, StatusCode> { diff --git a/src/server.rs b/src/server.rs index 1be31c01..831eb49a 100644 --- a/src/server.rs +++ b/src/server.rs @@ -75,8 +75,9 @@ pub async fn serve(db: DatabaseConnection, domain: String) { let app = Router::new() // core server inbox/outbox, maybe for feeds? TODO do we need these? .route("/", get(ap::view)) - .route("/inbox", post(ap::inbox)) - .route("/outbox", get(ap::outbox)) + // TODO shared inboxes and instance stream will come later, just use users *boxes for now + // .route("/inbox", post(ap::inbox)) + // .route("/outbox", get(ap::outbox)) // .well-known and discovery .route("/.well-known/webfinger", get(ap::well_known::webfinger)) .route("/.well-known/host-meta", get(ap::well_known::host_meta))