fix: persist inbound Block to blocklist, clear on Undo(Block)
Closes #1
This commit is contained in:
@@ -46,17 +46,22 @@ impl Activity for BlockActivity {
|
||||
if check_guards(&self.id, self.actor.inner(), data).await? {
|
||||
return Ok(());
|
||||
}
|
||||
let actor_url = self.actor.inner().as_str();
|
||||
if let Some(local_user_id) = crate::urls::extract_user_id_from_url(&self.object) {
|
||||
let _ = data
|
||||
.follow_repo
|
||||
.remove_following(local_user_id, self.actor.inner().as_str())
|
||||
.remove_following(local_user_id, actor_url)
|
||||
.await;
|
||||
let _ = data
|
||||
.follow_repo
|
||||
.remove_follower(local_user_id, self.actor.inner().as_str())
|
||||
.remove_follower(local_user_id, actor_url)
|
||||
.await;
|
||||
let _ = data
|
||||
.blocklist_repo
|
||||
.add_blocked_actor(local_user_id, actor_url)
|
||||
.await;
|
||||
}
|
||||
tracing::info!(actor = %self.actor.inner(), "received block — removed following and follower");
|
||||
tracing::info!(actor = %actor_url, "received block — removed relationships, recorded in blocklist");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,11 +128,18 @@ impl Activity for UndoActivity {
|
||||
tracing::info!(actor = %self.actor.inner(), "received Undo(Announce)");
|
||||
}
|
||||
"Block" => {
|
||||
// Remote actor unblocked a local user. No automatic relationship
|
||||
// restoration — the blocked user would need to re-follow manually.
|
||||
if let Some(obj_url) = self.object.get("object").and_then(|o| o.as_str())
|
||||
&& let Ok(url) = Url::parse(obj_url)
|
||||
&& let Some(user_id) = crate::urls::extract_user_id_from_url(&url)
|
||||
{
|
||||
let _ = data
|
||||
.blocklist_repo
|
||||
.remove_blocked_actor(user_id, self.actor.inner().as_str())
|
||||
.await;
|
||||
}
|
||||
tracing::info!(
|
||||
actor = %self.actor.inner(),
|
||||
"received Undo(Block) — no automatic action taken"
|
||||
"received Undo(Block) — removed from blocklist"
|
||||
);
|
||||
}
|
||||
other => {
|
||||
|
||||
Reference in New Issue
Block a user