add: block list stacks
This commit is contained in:
parent
9bb5f38f76
commit
b71ae1f5a4
28 changed files with 700 additions and 219 deletions
|
@ -346,4 +346,41 @@ impl DataManager {
|
|||
// return
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_userfollow_sudo(&self, id: usize, user_id: usize) -> Result<()> {
|
||||
let follow = self.get_userfollow_by_id(id).await?;
|
||||
|
||||
let conn = match self.0.connect().await {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||
};
|
||||
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"DELETE FROM userfollows WHERE id = $1",
|
||||
&[&(id as i64)]
|
||||
);
|
||||
|
||||
if let Err(e) = res {
|
||||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
self.0.1.remove(format!("atto.userfollow:{}", id)).await;
|
||||
|
||||
// decr counts
|
||||
if follow.initiator != user_id {
|
||||
self.decr_user_following_count(follow.initiator)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
if follow.receiver != user_id {
|
||||
self.decr_user_follower_count(follow.receiver)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// return
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue