alias Pleroma.Web.Streamer
alias Pleroma.Workers.BackgroundWorker
+ require Logger
+
def handle(object, meta \\ [])
# Tasks this handle
# - Stream out the activity
def handle(%{data: %{"type" => "Delete", "object" => deleted_object}} = object, meta) do
deleted_object =
- Object.normalize(deleted_object, false) || User.get_cached_by_ap_id(deleted_object)
+ Object.normalize(deleted_object, false) ||
+ User.get_cached_by_ap_id(deleted_object)
result =
case deleted_object do
%Object{} ->
with {:ok, deleted_object, activity} <- Object.delete(deleted_object),
- %User{} = user <- User.get_cached_by_ap_id(deleted_object.data["actor"]) do
+ {_, actor} when is_binary(actor) <- {:actor, deleted_object.data["actor"]},
+ %User{} = user <- User.get_cached_by_ap_id(actor) do
User.remove_pinnned_activity(user, activity)
{:ok, user} = ActivityPub.decrease_note_count_if_public(user, deleted_object)
ActivityPub.stream_out(object)
ActivityPub.stream_out_participations(deleted_object, user)
:ok
+ else
+ {:actor, _} ->
+ Logger.error("The object doesn't have an actor: #{inspect(deleted_object)}")
+ :no_object_actor
end
%User{} ->
alias Pleroma.Web.ActivityPub.SideEffects
alias Pleroma.Web.CommonAPI
- import Pleroma.Factory
+ import ExUnit.CaptureLog
import Mock
+ import Pleroma.Factory
describe "handle_after_transaction" do
test "it streams out notifications and streams" do
assert User.get_cached_by_ap_id(user.ap_id).deactivated
end
+
+ test "it logs issues with objects deletion", %{
+ delete: delete,
+ object: object
+ } do
+ {:ok, object} =
+ object
+ |> Object.change(%{data: Map.delete(object.data, "actor")})
+ |> Repo.update()
+
+ Object.invalid_object_cache(object)
+
+ assert capture_log(fn ->
+ {:error, :no_object_actor} = SideEffects.handle(delete)
+ end) =~ "object doesn't have an actor"
+ end
end
describe "EmojiReact objects" do