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.ObjectValidators.CommonFixes do
6 alias Pleroma.Web.ActivityPub.Utils
8 # based on Pleroma.Web.ActivityPub.Utils.lazy_put_objects_defaults
9 def fix_defaults(data) do
10 %{data: %{"id" => context}, id: context_id} =
11 Utils.create_context(data["context"] || data["conversation"])
14 |> Map.put_new("context", context)
15 |> Map.put_new("context_id", context_id)
18 def fix_attribution(data) do
20 |> Map.put_new("actor", data["attributedTo"])