+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Object.Containment do
@moduledoc """
- # Object Containment
-
This module contains some useful functions for containing objects to specific
origins and determining those origins. They previously lived in the
ActivityPub `Transmogrifier` module.
Object containment is an important step in validating remote objects to prevent
spoofing, therefore removal of object containment functions is NOT recommended.
"""
-
- require Logger
-
def get_actor(%{"actor" => actor}) when is_binary(actor) do
actor
end
@doc """
Checks that an imported AP object's actor matches the domain it came from.
"""
- def contain_origin(id, %{"actor" => nil}), do: :error
+ def contain_origin(_id, %{"actor" => nil}), do: :error
- def contain_origin(id, %{"actor" => actor} = params) do
+ def contain_origin(id, %{"actor" => _actor} = params) do
id_uri = URI.parse(id)
actor_uri = URI.parse(get_actor(params))
end
end
- def contain_origin_from_id(id, %{"id" => nil}), do: :error
+ def contain_origin_from_id(_id, %{"id" => nil}), do: :error
- def contain_origin_from_id(id, %{"id" => other_id} = params) do
+ def contain_origin_from_id(id, %{"id" => other_id} = _params) do
id_uri = URI.parse(id)
other_uri = URI.parse(other_id)