1
0
Fork 0
forked from alemi/upub

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
This commit is contained in:
əlemi 2024-03-22 01:56:06 +01:00
parent 20415a0386
commit 7751114bda
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 7 additions and 33 deletions

View file

@ -47,41 +47,14 @@ pub async fn view(State(ctx): State<Context>) -> Result<Json<serde_json::Value>,
.set_id(Some(&url!(ctx, ""))) .set_id(Some(&url!(ctx, "")))
.set_name(Some("μpub")) .set_name(Some("μpub"))
.set_summary(Some("micro social network, federated")) .set_summary(Some("micro social network, federated"))
.set_inbox(Node::link(url!(ctx, "/inbox"))) // .set_inbox(Node::link(url!(ctx, "/inbox")))
.set_outbox(Node::link(url!(ctx, "/outbox"))) // .set_outbox(Node::link(url!(ctx, "/outbox")))
.ld_context() .ld_context()
)) ))
} }
pub async fn inbox(State(ctx) : State<Context>, Json(object): Json<serde_json::Value>) -> Result<JsonLD<serde_json::Value>, StatusCode> { pub async fn inbox(State(_ctx) : State<Context>, Json(_object): Json<serde_json::Value>) -> Result<JsonLD<serde_json::Value>, StatusCode> {
match object.base_type() { todo!()
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 outbox(State(_db): State<Context>) -> Result<Json<serde_json::Value>, StatusCode> { pub async fn outbox(State(_db): State<Context>) -> Result<Json<serde_json::Value>, StatusCode> {

View file

@ -75,8 +75,9 @@ pub async fn serve(db: DatabaseConnection, domain: String) {
let app = Router::new() let app = Router::new()
// core server inbox/outbox, maybe for feeds? TODO do we need these? // core server inbox/outbox, maybe for feeds? TODO do we need these?
.route("/", get(ap::view)) .route("/", get(ap::view))
.route("/inbox", post(ap::inbox)) // TODO shared inboxes and instance stream will come later, just use users *boxes for now
.route("/outbox", get(ap::outbox)) // .route("/inbox", post(ap::inbox))
// .route("/outbox", get(ap::outbox))
// .well-known and discovery // .well-known and discovery
.route("/.well-known/webfinger", get(ap::well_known::webfinger)) .route("/.well-known/webfinger", get(ap::well_known::webfinger))
.route("/.well-known/host-meta", get(ap::well_known::host_meta)) .route("/.well-known/host-meta", get(ap::well_known::host_meta))