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.EventValidator do
8 alias Pleroma.Web.ActivityPub.ObjectValidators.CommonFixes
9 alias Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
10 alias Pleroma.Web.ActivityPub.Transmogrifier
17 # Extends from NoteValidator
21 import Elixir.Pleroma.Web.ActivityPub.ObjectValidators.CommonFields
24 status_object_fields()
29 def cast_and_apply(data) do
32 |> apply_action(:insert)
35 def cast_and_validate(data) do
41 def cast_data(data) do
48 |> CommonFixes.fix_actor()
49 |> CommonFixes.fix_object_defaults()
50 |> Transmogrifier.fix_emoji()
53 def changeset(struct, data) do
57 |> cast(data, __schema__(:fields) -- [:attachment, :tag])
58 |> cast_embed(:attachment)
62 defp validate_data(data_cng) do
64 |> validate_inclusion(:type, ["Event"])
65 |> validate_required([:id, :actor, :attributedTo, :type, :context, :context_id])
66 |> CommonValidations.validate_any_presence([:cc, :to])
67 |> CommonValidations.validate_fields_match([:actor, :attributedTo])
68 |> CommonValidations.validate_actor_presence()
69 |> CommonValidations.validate_host_match()