# - Delete and unpins the create activity
# - Replace object with Tombstone
# - Set up notification
+ # - Reduce the user note count
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)
%User{} = user <- User.get_cached_by_ap_id(deleted_object.data["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
%{user: user, delete: delete, post: post, object: object, delete_user: delete_user}
end
- test "it handles object deletions", %{delete: delete, post: post, object: object} do
+ test "it handles object deletions", %{delete: delete, post: post, object: object, user: user} do
# In object deletions, the object is replaced by a tombstone and the
# create activity is deleted.
- with_mock Pleroma.Web.ActivityPub.ActivityPub,
+ with_mock Pleroma.Web.ActivityPub.ActivityPub, [:passthrough],
stream_out: fn _ -> nil end,
stream_out_participations: fn _, _ -> nil end do
{:ok, delete, _} = SideEffects.handle(delete)
user = User.get_cached_by_ap_id(object.data["actor"])
+
assert called(Pleroma.Web.ActivityPub.ActivityPub.stream_out(delete))
assert called(Pleroma.Web.ActivityPub.ActivityPub.stream_out_participations(object, user))
end
object = Object.get_by_id(object.id)
assert object.data["type"] == "Tombstone"
refute Activity.get_by_id(post.id)
+
+ user = User.get_by_id(user.id)
+ assert user.note_count == 0
end
test "it handles user deletions", %{delete_user: delete, user: user} do