ActivityPub create: discard activities from deactivated users
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 13 May 2018 23:28:56 +0000 (23:28 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 14 May 2018 00:05:02 +0000 (19:05 -0500)
lib/pleroma/web/activity_pub/activity_pub.ex

index 491ad370592faacfeeabe39ec30aee1a8a0c0df7..76cda0b4cab10db2d0e983b9bf0e407211c6d3b6 100644 (file)
@@ -16,9 +16,20 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     (data["to"] || []) ++ (data["cc"] || [])
   end
 
+  defp check_actor_is_active(actor) do
+    user = User.get_cached_by_ap_id(actor)
+
+    if user.info["deactivated"] == true do
+      :reject
+    else
+      :ok
+    end
+  end
+
   def insert(map, local \\ true) when is_map(map) do
     with nil <- Activity.get_by_ap_id(map["id"]),
          map <- lazy_put_activity_defaults(map),
+         :ok <- check_actor_is_active(map["actor"]),
          {:ok, map} <- MRF.filter(map),
          :ok <- insert_full_object(map) do
       {:ok, activity} =