1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.ObjectValidator do
7 This module is responsible for validating an object (which can be an activity)
8 and checking if it is both well formed and also compatible with our view of
14 alias Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator
16 @spec validate(map(), keyword()) :: {:ok, map(), keyword()} | {:error, any()}
17 def validate(object, meta)
19 def validate(%{"type" => "Like"} = object, meta) do
21 object |> LikeValidator.cast_and_validate() |> Ecto.Changeset.apply_action(:insert) do
22 object = stringify_keys(object |> Map.from_struct())
27 def stringify_keys(object) do
29 |> Map.new(fn {key, val} -> {to_string(key), val} end)
32 def fetch_actor_and_object(object) do
33 User.get_or_fetch_by_ap_id(object["actor"])
34 Object.normalize(object["object"])