Add Activity trait with 'deliver'
This commit is contained in:
parent
07fefa5b13
commit
4bc6f27288
|
@ -8,3 +8,12 @@ pub trait Client<'a> {
|
|||
fn deliver<T: serde::ser::Serialize>(&'a self, inbox: &'a Url, activity: &'a T)
|
||||
-> Self::Future;
|
||||
}
|
||||
|
||||
pub trait Activity<'a>: serde::ser::Serialize {
|
||||
fn deliver<C: Client<'a>>(&'a self, inbox: &'a Url, client: &'a C) -> C::Future
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
client.deliver(inbox, self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use apub_awc::{AwcClient, SignatureConfig};
|
||||
use apub_breaker_session::BreakerSession;
|
||||
use apub_core::session::RequestCountSession;
|
||||
use apub_core::{deliver::Activity, session::RequestCountSession};
|
||||
use apub_rustcrypto::Rustcrypto;
|
||||
use example_types::{object_id, NoteType, ObjectId};
|
||||
use rsa::RsaPrivateKey;
|
||||
|
|
|
@ -2,7 +2,7 @@ use actix_rt::Arbiter;
|
|||
use apub_awc::{AwcClient, SignatureConfig};
|
||||
use apub_background_jobs::{client, ClientFactoryBuilder, DeliverJob};
|
||||
use apub_breaker_session::BreakerSession;
|
||||
use apub_core::session::RequestCountSession;
|
||||
use apub_core::{deliver::Activity, session::RequestCountSession};
|
||||
use apub_rustcrypto::Rustcrypto;
|
||||
use background_jobs::{create_server_in_arbiter, memory_storage::Storage, WorkerConfig};
|
||||
use example_types::{object_id, Note, NoteType};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use apub_core::{
|
||||
deliver::Client,
|
||||
deliver::Activity,
|
||||
deref::{Dereference, Repo},
|
||||
};
|
||||
use std::{
|
||||
|
@ -86,15 +86,4 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl Note {
|
||||
pub async fn deliver<'a, C>(
|
||||
&'a self,
|
||||
inbox: &'a Url,
|
||||
client: &'a C,
|
||||
) -> Result<(), Box<dyn std::error::Error>>
|
||||
where
|
||||
C: Client<'a>,
|
||||
{
|
||||
Ok(client.deliver(inbox, self).await?)
|
||||
}
|
||||
}
|
||||
impl<'a> Activity<'a> for Note {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use apub_breaker_session::BreakerSession;
|
||||
use apub_core::session::RequestCountSession;
|
||||
use apub_core::{deliver::Activity, session::RequestCountSession};
|
||||
use apub_openssl::OpenSsl;
|
||||
use apub_reqwest::{ReqwestClient, SignatureConfig};
|
||||
use example_types::{object_id, NoteType, ObjectId};
|
||||
|
|
Loading…
Reference in a new issue