Delete accepted follow request when unfollowing actor
This commit is contained in:
parent
8d5cabc08b
commit
f785541205
1 changed files with 11 additions and 11 deletions
|
@ -118,17 +118,17 @@ pub async fn unfollow(
|
||||||
",
|
",
|
||||||
&[&source_id, &target_id],
|
&[&source_id, &target_id],
|
||||||
).await?;
|
).await?;
|
||||||
if deleted_count == 0 {
|
let relationship_deleted = deleted_count > 0;
|
||||||
// Relationship not found, try to delete follow request
|
// Delete follow request (for remote follows)
|
||||||
let follow_request_deleted = delete_follow_request(
|
let follow_request_deleted = delete_follow_request(
|
||||||
&transaction,
|
&transaction,
|
||||||
source_id,
|
source_id,
|
||||||
target_id,
|
target_id,
|
||||||
).await?;
|
).await?;
|
||||||
if !follow_request_deleted {
|
if !relationship_deleted && !follow_request_deleted {
|
||||||
return Err(DatabaseError::NotFound("relationship"));
|
return Err(DatabaseError::NotFound("relationship"));
|
||||||
}
|
};
|
||||||
} else {
|
if relationship_deleted {
|
||||||
// Update counters only if relationship exists
|
// Update counters only if relationship exists
|
||||||
update_follower_count(&transaction, target_id, -1).await?;
|
update_follower_count(&transaction, target_id, -1).await?;
|
||||||
update_following_count(&transaction, source_id, -1).await?;
|
update_following_count(&transaction, source_id, -1).await?;
|
||||||
|
|
Loading…
Reference in a new issue