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
|> add_attributed_to
|> prepare_attachments
|> set_conversation
+ |> set_reply_to_uri
end
@doc
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