hyaenidae/profiles/src/apub/actions/follow.rs
asonix ab8aa2cbe1 Profiles: expose needed information for non-apub profile creation
- Add image purge to profile update
- Add outbound processing in apub ingest
- Add follower + follow request cleanup in profile delete
- Add inboxes + id to Outbound trait
2021-01-06 02:21:17 -06:00

47 lines
1.7 KiB
Rust

use crate::{
apub::actions::{UndoAcceptFollow, UndoFollow},
Action, Context, Error, Outbound, Required,
};
impl Action for UndoFollow {
fn perform(&self, context: &Context) -> Result<Option<Box<dyn Outbound>>, Error> {
let opt = context.store.view.follows.remove(self.follow_id)?;
let accept_apub_id = context.apub.apub_for_follow(self.follow_id)?.req()?;
context.apub.delete_object(&accept_apub_id)?;
context.apub.delete_object(&self.follow_apub_id)?;
if let Some(undo_follow) = opt {
if context.is_local(undo_follow.0.right)? {
return Ok(Some(Box::new(crate::apub::results::UndoFollow {
follow_apub_id: self.follow_apub_id.clone(),
profile_id: undo_follow.0.right,
followed_id: undo_follow.0.left,
})));
}
}
Ok(None)
}
}
impl Action for UndoAcceptFollow {
fn perform(&self, context: &Context) -> Result<Option<Box<dyn Outbound>>, Error> {
let opt = context.store.view.follows.remove(self.follow_id)?;
let accept_apub_id = context.apub.apub_for_follow(self.follow_id)?.req()?;
context.apub.delete_object(&accept_apub_id)?;
context.apub.delete_object(&self.follow_apub_id)?;
if let Some(undo_follow) = opt {
if context.is_local(undo_follow.0.right)? {
return Ok(Some(Box::new(crate::apub::results::UndoAcceptFollow {
accept_apub_id,
profile_id: undo_follow.0.left,
requester_id: undo_follow.0.right,
})));
}
}
Ok(None)
}
}