activitypub: use Object.delete() instead of mutating the database and cache directly
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 1 Nov 2018 07:29:12 +0000 (07:29 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 1 Nov 2018 07:29:12 +0000 (07:29 +0000)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/common_api/common_api.ex

index 5a81f6fa2b2bb7c64643dae028e7955801e7d109..48ae36ebd58fb4802d30a9fd498f3d91e01a09ce 100644 (file)
@@ -273,8 +273,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       "to" => [user.follower_address, "https://www.w3.org/ns/activitystreams#Public"]
     }
 
-    with Repo.delete(object),
-         Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id)),
+    with Object.delete(object),
          {:ok, activity} <- insert(data, local),
          :ok <- maybe_federate(activity),
          {:ok, _actor} <- User.decrease_note_count(user) do
index 8607cb6b3010c4babf22f3c4cc94b7e5cef92746..8f47bb12785aa0e12ee092473dfd36a46203b140 100644 (file)
@@ -9,8 +9,7 @@ defmodule Pleroma.Web.CommonAPI do
     with %Activity{data: %{"object" => %{"id" => object_id}}} <- Repo.get(Activity, activity_id),
          %Object{} = object <- Object.normalize(object_id),
          true <- user.info["is_moderator"] || user.ap_id == object.data["actor"],
-         {:ok, delete} <- ActivityPub.delete(object),
-         {:ok, true} <- Cachex.del(:user_cache, "object:#{object_id}") do
+         {:ok, delete} <- ActivityPub.delete(object) do
       {:ok, delete}
     end
   end