2023-02-19 17:56:01 +05:30
|
|
|
use crate::{activities::follow::Follow, instance::DatabaseHandle, objects::person::DbUser};
|
2023-02-11 18:02:35 +05:30
|
|
|
use activitypub_federation::{
|
2023-03-02 04:49:10 +05:30
|
|
|
config::RequestData,
|
2023-02-11 18:02:35 +05:30
|
|
|
core::object_id::ObjectId,
|
2023-02-19 17:56:01 +05:30
|
|
|
kinds::activity::AcceptType,
|
2023-02-11 18:02:35 +05:30
|
|
|
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 {
|
2023-02-19 17:56:01 +05:30
|
|
|
actor: ObjectId<DbUser>,
|
2022-06-02 16:47:12 +05:30
|
|
|
object: Follow,
|
|
|
|
#[serde(rename = "type")]
|
|
|
|
kind: AcceptType,
|
|
|
|
id: Url,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Accept {
|
2023-02-19 17:56:01 +05:30
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-29 02:49:56 +05:30
|
|
|
#[async_trait::async_trait]
|
2022-06-02 16:47:12 +05:30
|
|
|
impl ActivityHandler for Accept {
|
2023-02-11 18:02:35 +05:30
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
2023-02-11 18:02:35 +05:30
|
|
|
async fn receive(self, _data: &RequestData<Self::DataType>) -> Result<(), Self::Error> {
|
2022-06-02 16:47:12 +05:30
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|