use crate::{ apub::actions::{UndoAcceptFollow, UndoFollow}, Action, Context, Error, Outbound, Required, }; impl Action for UndoFollow { fn perform(&self, context: &Context) -> Result>, 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>, 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) } }