Transmogrifier: fetch quoted post
This commit is contained in:
parent
795736af16
commit
b022d6635d
5 changed files with 165 additions and 0 deletions
|
|
@ -166,6 +166,22 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
|
||||
def fix_in_reply_to(object, _options), do: object
|
||||
|
||||
def fix_quote(object, options \\ [])
|
||||
|
||||
def fix_quote(%{"quoteUrl" => quote_url} = object, options)
|
||||
when not is_nil(quote_url) do
|
||||
with {:ok, quoted_object} <- get_obj_helper(quote_url, options),
|
||||
%Activity{} <- Activity.get_create_by_object_ap_id(quoted_object.data["id"]) do
|
||||
Map.put(object, "quoteUrl", quoted_object.data["id"])
|
||||
else
|
||||
e ->
|
||||
Logger.warn("Couldn't fetch #{inspect(quote_url)}, error: #{inspect(e)}")
|
||||
object
|
||||
end
|
||||
end
|
||||
|
||||
def fix_quote(object, _options), do: object
|
||||
|
||||
defp prepare_in_reply_to(in_reply_to) do
|
||||
cond do
|
||||
is_bitstring(in_reply_to) ->
|
||||
|
|
@ -454,6 +470,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
|> strip_internal_fields()
|
||||
|> fix_type(fetch_options)
|
||||
|> fix_in_reply_to(fetch_options)
|
||||
|> fix_quote(fetch_options)
|
||||
|
||||
data = Map.put(data, "object", object)
|
||||
options = Keyword.put(options, :local, false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue