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:
parent
20415a0386
commit
7751114bda
2 changed files with 7 additions and 33 deletions
|
@ -47,41 +47,14 @@ pub async fn view(State(ctx): State<Context>) -> Result<Json<serde_json::Value>,
|
|||
.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<Context>, Json(object): Json<serde_json::Value>) -> Result<JsonLD<serde_json::Value>, 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<Context>, Json(_object): Json<serde_json::Value>) -> Result<JsonLD<serde_json::Value>, StatusCode> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub async fn outbox(State(_db): State<Context>) -> Result<Json<serde_json::Value>, StatusCode> {
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue