Use user url in mention if we have it.
authorlain <lain@soykaf.club>
Tue, 3 Apr 2018 16:32:46 +0000 (18:32 +0200)
committerlain <lain@soykaf.club>
Tue, 3 Apr 2018 16:32:46 +0000 (18:32 +0200)
lib/pleroma/formatter.ex
test/formatter_test.exs

index 9396b182682cd2dd99b4b35b8341e68df20b8970..3634a8f5bd5292520559dfa01be2528b7ff878f5 100644 (file)
@@ -189,7 +189,9 @@ defmodule Pleroma.Formatter do
 
     subs =
       subs ++
-        Enum.map(mentions, fn {match, %User{ap_id: ap_id}, uuid} ->
+        Enum.map(mentions, fn {match, %User{ap_id: ap_id, info: info}, uuid} ->
+          ap_id = info["source_data"]["url"] || ap_id
+
           short_match = String.split(match, "@") |> tl() |> hd()
           {uuid, "<span><a href='#{ap_id}'>@<span>#{short_match}</span></a></span>"}
         end)
index b7246252f732c1b7410339f45d5a016cc17a6c80..d9cef8abc53e77b5bc9c148aee7c7e33ce9cf05a 100644 (file)
@@ -64,7 +64,13 @@ defmodule Pleroma.FormatterTest do
     test "gives a replacement for user links" do
       text = "@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme@archae.me"
       gsimg = insert(:user, %{nickname: "gsimg"})
-      archaeme = insert(:user, %{nickname: "archaeme"})
+
+      archaeme =
+        insert(:user, %{
+          nickname: "archaeme",
+          info: %{"source_data" => %{"url" => "https://archeme/@archaeme"}}
+        })
+
       archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})
 
       mentions = Pleroma.Formatter.parse_mentions(text)
@@ -76,7 +82,7 @@ defmodule Pleroma.FormatterTest do
 
       expected_text =
         "<span><a href='#{gsimg.ap_id}'>@<span>gsimg</span></a></span> According to <span><a href='#{
-          archaeme.ap_id
+          "https://archeme/@archaeme"
         }'>@<span>archaeme</span></a></span>, that is @daggsy. Also hello <span><a href='#{
           archaeme_remote.ap_id
         }'>@<span>archaeme</span></a></span>"