summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-04-01 07:15:38 +0200
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-04-10 06:20:02 +0200
commit369c03834c5f2638080ff515055723e6c1c716bf (patch)
tree32d60a3a6f54084a7ef55ecd877a9849da18f267
parentb6bed1a284ce07359642e0a884d2476ca387439d (diff)
downloadpleroma-369c03834c5f2638080ff515055723e6c1c716bf.tar.gz
pleroma-369c03834c5f2638080ff515055723e6c1c716bf.zip
formatter: Use user.uri instead of user.source_data.uri
-rw-r--r--lib/pleroma/formatter.ex7
-rw-r--r--test/formatter_test.exs2
2 files changed, 3 insertions, 6 deletions
diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex
index c44e7fc8b..02a93a8dc 100644
--- a/lib/pleroma/formatter.ex
+++ b/lib/pleroma/formatter.ex
@@ -31,7 +31,7 @@ defmodule Pleroma.Formatter do
def mention_handler("@" <> nickname, buffer, opts, acc) do
case User.get_cached_by_nickname(nickname) do
%User{id: id} = user ->
- ap_id = get_ap_id(user)
+ user_url = user.uri || user.ap_id
nickname_text = get_nickname_text(nickname, opts)
link =
@@ -42,7 +42,7 @@ defmodule Pleroma.Formatter do
["@", Phoenix.HTML.Tag.content_tag(:span, nickname_text)],
"data-user": id,
class: "u-url mention",
- href: ap_id,
+ href: user_url,
rel: "ugc"
),
class: "h-card"
@@ -146,9 +146,6 @@ defmodule Pleroma.Formatter do
end
end
- defp get_ap_id(%User{source_data: %{"url" => url}}) when is_binary(url), do: url
- defp get_ap_id(%User{ap_id: ap_id}), do: ap_id
-
defp get_nickname_text(nickname, %{mentions_format: :full}), do: User.full_nickname(nickname)
defp get_nickname_text(nickname, _), do: User.local_nickname(nickname)
end
diff --git a/test/formatter_test.exs b/test/formatter_test.exs
index 93fd8eab7..bef5a2c28 100644
--- a/test/formatter_test.exs
+++ b/test/formatter_test.exs
@@ -140,7 +140,7 @@ defmodule Pleroma.FormatterTest do
archaeme =
insert(:user,
nickname: "archa_eme_",
- source_data: %{"url" => "https://archeme/@archa_eme_"}
+ uri: "https://archeme/@archa_eme_"
)
archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})