mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-26 21:41:04 +00:00
Implement AsObject07<User, Undo07, &DbConn> for Follow
This commit is contained in:
parent
fb5027becd
commit
73009818f2
1 changed files with 21 additions and 0 deletions
|
@ -363,6 +363,27 @@ impl AsObject<User, Undo, &DbConn> for Follow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsObject07<User, Undo07, &DbConn> for Follow {
|
||||||
|
type Error = Error;
|
||||||
|
type Output = ();
|
||||||
|
|
||||||
|
fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
|
||||||
|
let conn = conn;
|
||||||
|
if self.follower_id == actor.id {
|
||||||
|
diesel::delete(&self).execute(&**conn)?;
|
||||||
|
|
||||||
|
// delete associated notification if any
|
||||||
|
if let Ok(notif) = Notification::find(conn, notification_kind::FOLLOW, self.id) {
|
||||||
|
diesel::delete(¬if).execute(&**conn)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(Error::Unauthorized)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl IntoId for Follow {
|
impl IntoId for Follow {
|
||||||
fn into_id(self) -> Id {
|
fn into_id(self) -> Id {
|
||||||
Id::new(self.ap_url)
|
Id::new(self.ap_url)
|
||||||
|
|
Loading…
Reference in a new issue