From e5206752e163affc3c0b7bca506e89a6249f5702 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 26 May 2018 14:55:16 +0000 Subject: [PATCH] activitypub: only send accept back automatically if the account is not locked --- lib/pleroma/user.ex | 4 ++++ lib/pleroma/web/activity_pub/transmogrifier.ex | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 00cac153d..c7b7b4f0a 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -252,6 +252,10 @@ defmodule Pleroma.User do Enum.member?(follower.following, followed.follower_address) end + def locked?(%User{} = user) do + user.info["locked"] || false + end + def get_by_ap_id(ap_id) do Repo.get_by(User, ap_id: ap_id) end diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 75ba36729..7b0d124b2 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -137,9 +137,11 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do with %User{local: true} = followed <- User.get_cached_by_ap_id(followed), %User{} = follower <- User.get_or_fetch_by_ap_id(follower), {:ok, activity} <- ActivityPub.follow(follower, followed, id, false) do - ActivityPub.accept(%{to: [follower.ap_id], actor: followed.ap_id, object: data, local: true}) + if not User.locked?(followed) do + ActivityPub.accept(%{to: [follower.ap_id], actor: followed.ap_id, object: data, local: true}) + User.follow(follower, followed) + end - User.follow(follower, followed) {:ok, activity} else _e -> :error -- 2.45.2