From 25c733f4022f171a69cff9badfa8d625a3ad5b6b Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 1 Aug 2017 17:35:19 +0200 Subject: [PATCH] Add href to in-reply-to. THis should enable fetching from pleroma posts. --- lib/pleroma/web/ostatus/activity_representer.ex | 12 ++++++++++-- test/web/ostatus/activity_representer_test.exs | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/ostatus/activity_representer.ex b/lib/pleroma/web/ostatus/activity_representer.ex index a129fac23..842e44ee4 100644 --- a/lib/pleroma/web/ostatus/activity_representer.ex +++ b/lib/pleroma/web/ostatus/activity_representer.ex @@ -1,10 +1,18 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do - alias Pleroma.{Activity, User} + alias Pleroma.{Activity, User, Object} alias Pleroma.Web.OStatus.UserRepresenter require Logger + defp get_href(id) do + with %Object{data: %{ "external_url" => external_url } }<- Object.get_cached_by_ap_id(id) do + external_url + else + _e -> id + end + end + defp get_in_reply_to(%{"object" => %{"inReplyTo" => in_reply_to}}) do - [{:"thr:in-reply-to", [ref: to_charlist(in_reply_to)], []}] + [{:"thr:in-reply-to", [ref: to_charlist(in_reply_to), href: to_charlist(get_href(in_reply_to))], []}] end defp get_in_reply_to(_), do: [] diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 171a8bae7..0129e3758 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -58,6 +58,9 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do data = %{answer.data | "object" => object} answer = %{answer | data: data} + note_object = Object.get_by_ap_id(note.data["object"]["id"]) + Repo.update!(Object.change(note_object, %{ data: Map.put(note_object.data, "external_url", "someurl") })) + user = User.get_cached_by_ap_id(answer.data["actor"]) expected = """ @@ -73,7 +76,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do - + """ -- 2.45.2