For outgoing objects, fake mastodon style ap id for ostatus.
This commit is contained in:
parent
b72a25f5b1
commit
5da2355e71
@ -183,6 +183,17 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||
if object = Object.get_by_ap_id(id), do: {:ok, object}, else: nil
|
||||
end
|
||||
|
||||
def set_reply_to_uri(%{"inReplyTo" => inReplyTo} = object) do
|
||||
with false <- String.starts_with?(inReplyTo, "http"),
|
||||
{:ok, %{data: replied_to_object}} <- get_obj_helper(inReplyTo) do
|
||||
Map.put(object, "inReplyTo", replied_to_object["external_url"] || inReplyTo)
|
||||
else
|
||||
_e -> object
|
||||
end
|
||||
end
|
||||
def set_reply_to_uri(obj), do: obj
|
||||
|
||||
# Prepares the object of an outgoing create activity.
|
||||
def prepare_object(object) do
|
||||
object
|
||||
|> set_sensitive
|
||||
@ -192,6 +203,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||
|> add_attributed_to
|
||||
|> prepare_attachments
|
||||
|> set_conversation
|
||||
|> set_reply_to_uri
|
||||
end
|
||||
|
||||
@doc
|
||||
|
@ -233,6 +233,18 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||
|
||||
assert modified["object"] == "http://gs.example.org:4040/index.php/notice/29"
|
||||
end
|
||||
|
||||
test "it translates ostatus reply_to IDs to external URLs" do
|
||||
incoming = File.read!("test/fixtures/incoming_note_activity.xml")
|
||||
{:ok, [referred_activity]} = OStatus.handle_incoming(incoming)
|
||||
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!", "in_reply_to_status_id" => referred_activity.id})
|
||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
||||
assert modified["object"]["inReplyTo"] == "http://gs.example.org:4040/index.php/notice/29"
|
||||
end
|
||||
end
|
||||
|
||||
describe "user upgrade" do
|
||||
|
Loading…
Reference in New Issue
Block a user