From: kaniini Date: Wed, 20 Feb 2019 16:42:52 +0000 (+0000) Subject: Merge branch 'nicer-share-urls' into 'develop' X-Git-Url: http://git.squeep.com/?a=commitdiff_plain;h=77fb926afa53a6d156729b1dd1613e1fed0c7910;hp=dff5e1e46ab5e622ae0cc4b4422ae57ce0a0d5de;p=akkoma Merge branch 'nicer-share-urls' into 'develop' Add some nicer urls in status view. See merge request pleroma/pleroma!844 --- diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index a49b381c9..b90e4252a 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -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), diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index 0dc9c538c..3412a6be2 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -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,