gourami

[UNMAINTAINED] Activitypub server in Rust
Log | Files | Refs | README | LICENSE

commit 16c7a8ded0ecbfcaa3b7be228aef9561f801f395
parent c7e43431e43d1e4500bac22420a270ecdc404ee8
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Wed, 29 Apr 2020 16:56:46 -0500

Add activityPub routes

Diffstat:
Msrc/ap.rs | 11+++++++----
Msrc/routes.rs | 28++++++++++------------------
2 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/src/ap.rs b/src/ap.rs @@ -17,11 +17,10 @@ use crate::db::note::{RemoteNoteInput}; // gonna be big // // TODO -- use serde json here -fn process_unstructured_ap(message: &str) -> Result<(), Box<dyn std::error::Error>>{ +fn process_unstructured_ap(v: Value) -> Result<(), Box<dyn std::error::Error>>{ // Actions usually associated with notes // maybe there's a cleaner way to do this. cant iterate over types // TODO inbox forwarding https://www.w3.org/TR/activitypub/#inbox-forwarding - let v: Value = serde_json::from_str(message)?; let _type = v.get("type").ok_or("No type found")?; if _type == "Create" { let object = v.get("object").ok_or("No object found")?; @@ -120,9 +119,13 @@ mod tests { } } -pub fn post_inbox(user_name: String, message: Value) {} +pub fn post_inbox(message: Value) { + process_unstructured_ap(message); +} + +pub fn get_outbox() {} -pub fn post_outbox(user_name: String, message: Value) {} +pub fn post_outbox(message: Value) {} // TODO figure out how to follow mastodon // diff --git a/src/routes.rs b/src/routes.rs @@ -102,27 +102,19 @@ pub async fn run_server() { // activityPub stuff // This stuff should filter based on the application headers + // setup authentication // POST - // let post_server_inbox = path!("user" / String / "inbox.json" ) - // .and(json()) - // .map(ap::post_user_inbox); + // TODO -- setup proper replies + let post_server_inbox = path!("inbox.json" ) + .and(json()) + .map(ap::post_inbox); -// let post_user_outbox = path!("user" / String / "outbox.json" ) -// .and(json()) -// .map(ap::post_user_outbox); + let post_server_outbox = path!("outbox.json" ) + .and(json()) + .map(ap::post_outbox); -// let get_user_outbox = path!("user" / String / "outbox.json" ) -// .map(ap::get_user_outbox); - - // let get_user_inbox = path!("user" / String / "outbox.json" ) - // .and(json()) - // .map(ap::post_user_outbox); - -// let user_followers = path!("user" / String / "followers.json" ) -// .map(ap::user_followers); - -// let user_following = path!("user" / String / "following.json" ) -// .map(ap::user_following); + let get_server_outbox = path!("outbox.json" ) + .map(ap::get_outbox); // https://github.com/seanmonstar/warp/issues/42 -- how to set up diesel // TODO set content length limit