Commit 82e34cae authored by lain's avatar lain

Unify object representation.

parent 2b5d2659
Pipeline #838 failed with stage
in 2 minutes and 41 seconds
...@@ -122,18 +122,23 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do ...@@ -122,18 +122,23 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
if object = Object.get_by_ap_id(id), do: {:ok, object}, else: nil if object = Object.get_by_ap_id(id), do: {:ok, object}, else: nil
end end
@doc def prepare_object(object) do
""" object
internal -> Mastodon
"""
def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = object} = data) do
object = object
|> set_sensitive |> set_sensitive
|> add_hashtags |> add_hashtags
|> add_mention_tags |> add_mention_tags
|> add_attributed_to |> add_attributed_to
|> prepare_attachments |> prepare_attachments
|> set_conversation |> set_conversation
end
@doc
"""
internal -> Mastodon
"""
def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = object} = data) do
object = object
|> prepare_object
data = data data = data
|> Map.put("object", object) |> Map.put("object", object)
......
defmodule Pleroma.Web.ActivityPub.ObjectView do defmodule Pleroma.Web.ActivityPub.ObjectView do
use Pleroma.Web, :view use Pleroma.Web, :view
alias Pleroma.Web.ActivityPub.Transmogrifier
def render("object.json", %{object: object}) do def render("object.json", %{object: object}) do
base = %{ base = %{
...@@ -20,8 +21,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectView do ...@@ -20,8 +21,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectView do
] ]
} }
additional = Map.take(object.data, ["id", "to", "cc", "actor", "content", "summary", "type"]) additional = Transmogrifier.prepare_object(object.data)
|> Map.put("attributedTo", object.data["actor"])
Map.merge(base, additional) Map.merge(base, additional)
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment