1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 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
12 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
20 with {_, %{valid?: true, changes: object}} <-
21 {:validate_object, LikeValidator.cast_and_validate(object)} do
22 object = stringify_keys(object)
29 def stringify_keys(object) do
31 |> Enum.map(fn {key, val} -> {to_string(key), val} end)
35 def fetch_actor_and_object(object) do
36 User.get_or_fetch_by_ap_id(object["actor"])
37 Object.normalize(object["object"])