From f5fdc5dc632d136800dd765fdef6978373309e72 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Wed, 21 Jul 2021 21:03:24 +0200 Subject: [PATCH] object_validator: Simplify Add/Remove --- lib/pleroma/web/activity_pub/object_validator.ex | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/pleroma/web/activity_pub/object_validator.ex b/lib/pleroma/web/activity_pub/object_validator.ex index 6e40d8b72..0c0af2394 100644 --- a/lib/pleroma/web/activity_pub/object_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validator.ex @@ -143,7 +143,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do def validate(%{"type" => type} = object, meta) when type in ~w[Accept Reject Follow Update Like EmojiReact Announce - ChatMessage Answer] do + ChatMessage Answer Add Remove] do validator = case type do "Accept" -> AcceptRejectValidator @@ -155,6 +155,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do "Announce" -> AnnounceValidator "ChatMessage" -> ChatMessageValidator "Answer" -> AnswerValidator + "Add" -> AddRemoveValidator + "Remove" -> AddRemoveValidator end with {:ok, object} <- @@ -166,16 +168,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do end end - def validate(%{"type" => type} = object, meta) when type in ~w(Add Remove) do - with {:ok, object} <- - object - |> AddRemoveValidator.cast_and_validate() - |> Ecto.Changeset.apply_action(:insert) do - object = stringify_keys(object) - {:ok, object, meta} - end - end - def validate(o, m), do: {:error, {:validator_not_set, {o, m}}} def cast_and_apply(%{"type" => "ChatMessage"} = object) do