Remove depdendency on activitypub from plume-common

This commit is contained in:
Kitaiti Makoto
2022-01-12 03:32:06 +09:00
parent bb7267846f
commit 7a404c68df
4 changed files with 14 additions and 18 deletions
-1
View File
@@ -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"
+3 -3
View File
@@ -200,7 +200,7 @@ where
pub fn with<A, V, M>(self, proxy: Option<&reqwest::Proxy>) -> Inbox<'a, C, E, R>
where
A: AsActor<&'a C> + FromId<C, Error = E>,
V: activitypub::Activity,
V: serde::de::DeserializeOwned + serde::Serialize,
M: AsObject<A, V, &'a C, Error = E> + FromId<C, Error = E>,
M::Output: Into<R>,
{
@@ -333,7 +333,7 @@ pub trait FromId<C>: Sized {
type Error: From<InboxError<Self::Error>> + 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<C> {
/// ```
pub trait AsObject<A, V, C>
where
V: activitypub::Activity,
V: serde::de::DeserializeOwned + serde::Serialize,
{
/// What kind of error is returned when something fails
type Error;
+11 -13
View File
@@ -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>(T);
impl<T> ActivityStream<T> {
pub fn new(t: T) -> ActivityStream<T> {
impl<O: serde::Serialize> ActivityStream<ApObject<O>> {
pub fn new(t: ApObject<O>) -> ActivityStream<ApObject<O>> {
ActivityStream(t)
}
}
impl<'r, O: Object> Responder<'r> for ActivityStream<O> {
impl<'r, O: serde::Serialize> Responder<'r> for ActivityStream<ApObject<O>> {
fn respond_to(self, request: &Request<'_>) -> Result<Response<'r>, 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<S, A, T, C>(sender: &S, act: A, to: Vec<T>, proxy: Option<reqwest::Proxy>)
where
pub fn broadcast<S, A, T, C>(
sender: &S,
act: Activity<A>,
to: Vec<T>,
proxy: Option<reqwest::Proxy>,
) where
S: sign::Signer,
A: Activity,
A: serde::Serialize,
T: inbox::AsActor<C>,
{
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<serde_json::Value>,
}
impl Object for Licensed {}