2022-06-02 16:47:12 +05:30
|
|
|
use crate::{activities::follow::Follow, instance::InstanceHandle, objects::person::MyUser};
|
|
|
|
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
|
|
|
|
use activitystreams_kinds::activity::AcceptType;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use url::Url;
|
|
|
|
|
|
|
|
#[derive(Deserialize, Serialize, Debug)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct Accept {
|
|
|
|
actor: ObjectId<MyUser>,
|
|
|
|
object: Follow,
|
|
|
|
#[serde(rename = "type")]
|
|
|
|
kind: AcceptType,
|
|
|
|
id: Url,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Accept {
|
|
|
|
pub fn new(actor: ObjectId<MyUser>, object: Follow, id: Url) -> Accept {
|
|
|
|
Accept {
|
|
|
|
actor,
|
|
|
|
object,
|
|
|
|
kind: Default::default(),
|
|
|
|
id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-29 02:49:56 +05:30
|
|
|
#[async_trait::async_trait]
|
2022-06-02 16:47:12 +05:30
|
|
|
impl ActivityHandler for Accept {
|
|
|
|
type DataType = InstanceHandle;
|
|
|
|
type Error = crate::error::Error;
|
|
|
|
|
|
|
|
fn id(&self) -> &Url {
|
|
|
|
&self.id
|
|
|
|
}
|
|
|
|
|
|
|
|
fn actor(&self) -> &Url {
|
|
|
|
self.actor.inner()
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn receive(
|
|
|
|
self,
|
|
|
|
_data: &Data<Self::DataType>,
|
|
|
|
_request_counter: &mut i32,
|
|
|
|
) -> Result<(), Self::Error> {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|