activitypub-federation-rust/examples/local_federation/activities/accept.rs

49 lines
1.1 KiB
Rust
Raw Normal View History

use crate::{activities::follow::Follow, instance::DatabaseHandle, objects::person::DbUser};
use activitypub_federation::{
2023-03-02 04:49:10 +05:30
config::RequestData,
2023-03-06 06:47:34 +05:30
fetch::object_id::ObjectId,
kinds::activity::AcceptType,
traits::ActivityHandler,
};
2022-06-02 16:47:12 +05:30
use serde::{Deserialize, Serialize};
use url::Url;
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Accept {
actor: ObjectId<DbUser>,
2022-06-02 16:47:12 +05:30
object: Follow,
#[serde(rename = "type")]
kind: AcceptType,
id: Url,
}
impl Accept {
pub fn new(actor: ObjectId<DbUser>, object: Follow, id: Url) -> Accept {
2022-06-02 16:47:12 +05:30
Accept {
actor,
object,
kind: Default::default(),
id,
}
}
}
#[async_trait::async_trait]
2022-06-02 16:47:12 +05:30
impl ActivityHandler for Accept {
type DataType = DatabaseHandle;
2022-06-02 16:47:12 +05:30
type Error = crate::error::Error;
fn id(&self) -> &Url {
&self.id
}
fn actor(&self) -> &Url {
self.actor.inner()
}
async fn receive(self, _data: &RequestData<Self::DataType>) -> Result<(), Self::Error> {
2022-06-02 16:47:12 +05:30
Ok(())
}
}