diff --git a/Cargo.lock b/Cargo.lock index f42fb286..462422fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3102,7 +3102,6 @@ dependencies = [ name = "plume-common" version = "0.7.1-dev" dependencies = [ - "activitypub", "activitystreams", "activitystreams-derive", "activitystreams-traits", diff --git a/plume-common/Cargo.toml b/plume-common/Cargo.toml index e8a07660..db5dec5e 100644 --- a/plume-common/Cargo.toml +++ b/plume-common/Cargo.toml @@ -5,7 +5,6 @@ authors = ["Plume contributors"] edition = "2018" [dependencies] -activitypub = "0.1.1" activitystreams-derive = "0.1.1" activitystreams-traits = "0.1.0" array_tool = "1.0" diff --git a/plume-common/src/activity_pub/inbox.rs b/plume-common/src/activity_pub/inbox.rs index 48ba6c5f..fca99e4c 100644 --- a/plume-common/src/activity_pub/inbox.rs +++ b/plume-common/src/activity_pub/inbox.rs @@ -200,7 +200,7 @@ where pub fn with(self, proxy: Option<&reqwest::Proxy>) -> Inbox<'a, C, E, R> where A: AsActor<&'a C> + FromId, - V: activitypub::Activity, + V: serde::de::DeserializeOwned + serde::Serialize, M: AsObject + FromId, M::Output: Into, { @@ -333,7 +333,7 @@ pub trait FromId: Sized { type Error: From> + Debug; /// The ActivityPub object type representing Self - type Object: activitypub::Object; + type Object: serde::de::DeserializeOwned + serde::Serialize; /// Tries to get an instance of `Self` from an ActivityPub ID. /// @@ -521,7 +521,7 @@ pub trait AsActor { /// ``` pub trait AsObject where - V: activitypub::Activity, + V: serde::de::DeserializeOwned + serde::Serialize, { /// What kind of error is returned when something fails type Error; diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index 23b2b5f4..bdc375e5 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -1,4 +1,4 @@ -use activitypub::{Activity, Link, Object}; +use activitystreams::{activity::Activity, object::ApObject}; use array_tool::vec::Uniq; use reqwest::{header::HeaderValue, r#async::ClientBuilder, Url}; use rocket::{ @@ -57,13 +57,13 @@ pub fn context() -> serde_json::Value { pub struct ActivityStream(T); -impl ActivityStream { - pub fn new(t: T) -> ActivityStream { +impl ActivityStream> { + pub fn new(t: ApObject) -> ActivityStream> { ActivityStream(t) } } -impl<'r, O: Object> Responder<'r> for ActivityStream { +impl<'r, O: serde::Serialize> Responder<'r> for ActivityStream> { fn respond_to(self, request: &Request<'_>) -> Result, Status> { let mut json = serde_json::to_value(&self.0).map_err(|_| Status::InternalServerError)?; json["@context"] = context(); @@ -108,10 +108,14 @@ impl<'a, 'r> FromRequest<'a, 'r> for ApRequest { .unwrap_or(Outcome::Forward(())) } } -pub fn broadcast(sender: &S, act: A, to: Vec, proxy: Option) -where +pub fn broadcast( + sender: &S, + act: Activity, + to: Vec, + proxy: Option, +) where S: sign::Signer, - A: Activity, + A: serde::Serialize, T: inbox::AsActor, { let boxes = to @@ -204,8 +208,6 @@ pub trait IntoId { fn into_id(self) -> Id; } -impl Link for Id {} - #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] pub struct ApSignature { @@ -251,13 +253,9 @@ pub struct Source { pub content: String, } -impl Object for Source {} - #[derive(Clone, Debug, Default, Deserialize, Serialize, Properties)] #[serde(rename_all = "camelCase")] pub struct Licensed { #[activitystreams(concrete(String), functional)] pub license: Option, } - -impl Object for Licensed {}