1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidator do
9 alias Pleroma.EctoType.ActivityPub.ObjectValidators
12 import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
17 field(:id, ObjectValidators.ObjectID, primary_key: true)
19 field(:actor, ObjectValidators.ObjectID)
20 field(:to, ObjectValidators.Recipients, default: [])
21 field(:cc, ObjectValidators.Recipients, default: [])
22 field(:deleted_activity_id, ObjectValidators.ObjectID)
23 field(:object, ObjectValidators.ObjectID)
26 def cast_data(data) do
28 |> cast(data, __schema__(:fields))
31 def add_deleted_activity_id(cng) do
36 with %Activity{id: id} <- Activity.get_create_by_object_ap_id(object) do
38 |> put_change(:deleted_activity_id, id)
56 def validate_data(cng) do
58 |> validate_required([:id, :type, :actor, :to, :cc, :object])
59 |> validate_inclusion(:type, ["Delete"])
60 |> validate_actor_presence()
61 |> validate_modification_rights()
62 |> validate_object_or_user_presence(allowed_types: @deletable_types)
63 |> add_deleted_activity_id()
66 def do_not_federate?(cng) do
70 def cast_and_validate(data) do