activitypub: c2s: support using `source` field to reformat posts like friendica does
This commit is contained in:
parent
833161b5d2
commit
28d2bbfc0d
|
@ -227,6 +227,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
|||
|> Map.merge(Map.take(params, ["to", "cc"]))
|
||||
|> Map.put("attributedTo", user.ap_id())
|
||||
|> Transmogrifier.fix_object()
|
||||
|> Transmogrifier.reformat_object()
|
||||
|
||||
ActivityPub.create(%{
|
||||
to: params["to"],
|
||||
|
|
|
@ -12,6 +12,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
alias Pleroma.Repo
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.ActivityPub.Utils
|
||||
alias Pleroma.Formatter
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
|
@ -67,6 +68,28 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
end
|
||||
end
|
||||
|
||||
def reformat_object(
|
||||
%{"source" => %{"content" => content, "mediaType" => content_type}} = object
|
||||
)
|
||||
when content_type in ["text/plain", "text/markdown"] do
|
||||
with mentions <- Formatter.parse_mentions(content),
|
||||
tags <- Formatter.parse_tags(content),
|
||||
html <-
|
||||
Pleroma.Web.CommonAPI.Utils.make_content_html(
|
||||
content,
|
||||
mentions,
|
||||
[],
|
||||
tags,
|
||||
content_type,
|
||||
false
|
||||
) do
|
||||
object
|
||||
|> Map.put("content", html)
|
||||
end
|
||||
end
|
||||
|
||||
def reformat_object(object), do: object
|
||||
|
||||
@doc """
|
||||
Modifies an incoming AP object (mastodon format) to our internal format.
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue