Add some nicer urls in status view.
authorlain <lain@soykaf.club>
Wed, 20 Feb 2019 16:36:16 +0000 (17:36 +0100)
committerlain <lain@soykaf.club>
Wed, 20 Feb 2019 16:36:16 +0000 (17:36 +0100)
lib/pleroma/web/mastodon_api/views/status_view.ex
test/web/mastodon_api/status_view_test.exs

index a49b381c952ed4c8a5e99c91a9c72f00f8f9f0bc..b90e4252a3ab43c7d96e728ad5d601be57860a89 100644 (file)
@@ -144,10 +144,17 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
 
     card = render("card.json", Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity))
 
+    url =
+      if user.local do
+        Pleroma.Web.Router.Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity)
+      else
+        object["external_url"] || object["id"]
+      end
+
     %{
       id: to_string(activity.id),
       uri: object["id"],
-      url: object["external_url"] || object["id"],
+      url: url,
       account: AccountView.render("account.json", %{user: user}),
       in_reply_to_id: reply_to && to_string(reply_to.id),
       in_reply_to_account_id: reply_to_user && to_string(reply_to_user.id),
index 0dc9c538cb5b255cfa624e315feabda0c2a1db42..3412a6be2e0c81550fc4f6ee397ebdd2b7e93f69 100644 (file)
@@ -81,7 +81,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
     expected = %{
       id: to_string(note.id),
       uri: note.data["object"]["id"],
-      url: note.data["object"]["id"],
+      url: Pleroma.Web.Router.Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, note),
       account: AccountView.render("account.json", %{user: user}),
       in_reply_to_id: nil,
       in_reply_to_account_id: nil,