From c648cc8cf357a7e27e381b22c4b7fe382b80fe50 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 10 Apr 2020 13:26:06 +0200 Subject: [PATCH] Add to/cc (and a bunch of todo) --- server/src/apub/activities.rs | 12 ++++++++++-- server/src/routes/federation.rs | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/server/src/apub/activities.rs b/server/src/apub/activities.rs index 3968a8b00..ff0a4fc16 100644 --- a/server/src/apub/activities.rs +++ b/server/src/apub/activities.rs @@ -1,6 +1,8 @@ use crate::apub::{get_apub_protocol_string, get_following_instances}; +use crate::db::community::Community; use crate::db::post::Post; use crate::db::user::User_; +use crate::db::Crud; use activitystreams::activity::Create; use activitystreams::context; use diesel::PgConnection; @@ -9,18 +11,24 @@ use isahc::prelude::*; pub fn post_create(post: &Post, creator: &User_, conn: &PgConnection) -> Result<(), Error> { let page = post.as_page(conn)?; + let community = Community::read(conn, post.community_id)?; let mut create = Create::new(); create.object_props.set_context_xsd_any_uri(context())?; - // TODO: seems like the create activity needs its own id (and be fetchable there) create .object_props - .set_id(page.object_props.get_id().unwrap().to_string())?; + // TODO: seems like the create activity needs its own id (and be fetchable there) + .set_id(page.object_props.get_id().unwrap().to_string())? + // TODO: should to/cc go on the Create, or on the Post? or on both? + // TODO: handle privacy on the receiving side (at least ignore anything thats not public) + .set_to_xsd_any_uri("https://www.w3.org/ns/activitystreams#Public")? + .set_cc_xsd_any_uri(format!("{}/followers", community.actor_id))?; create .create_props .set_actor_xsd_any_uri(creator.actor_id.to_owned())?; create.create_props.set_object_base_box(page)?; let json = serde_json::to_string(&create)?; for i in get_following_instances() { + // TODO: need to send this to the inbox of following users let inbox = format!( "{}://{}/federation/inbox", get_apub_protocol_string(), diff --git a/server/src/routes/federation.rs b/server/src/routes/federation.rs index c85d9d496..f4fffdad4 100644 --- a/server/src/routes/federation.rs +++ b/server/src/routes/federation.rs @@ -10,6 +10,7 @@ pub fn config(cfg: &mut web::ServiceConfig) { "/federation/communities", web::get().to(apub::community::get_apub_community_list), ) + // TODO: this needs to be moved to the actors (eg /federation/u/{}/inbox) .route( "/federation/inbox", web::post().to(apub::inbox::create_inbox),