[#491] Made user bio preserve full nicknames (nick@host).
authorIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 17 Jan 2019 15:03:49 +0000 (18:03 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 17 Jan 2019 15:03:49 +0000 (18:03 +0300)
lib/pleroma/formatter.ex
test/formatter_test.exs
test/web/twitter_api/views/user_view_test.exs

index 4149265a22a1e55454c9cc3f1e4235d290646782..024c6e11756bba6b4b46b07b1e4444469dfb1164 100644 (file)
@@ -142,12 +142,11 @@ defmodule Pleroma.Formatter do
               ap_id
             end
 
-          short_match = String.split(match, "@") |> tl() |> hd()
+          full_match = String.trim_leading(match, "@")
 
           {uuid,
-           "<span class='h-card'><a data-user='#{id}' class='u-url mention' href='#{ap_id}'>@<span>#{
-             short_match
-           }</span></a></span>"}
+           "<span class='h-card'><a data-user='#{id}' class='u-url mention' href='#{ap_id}'>" <>
+             "@<span>#{full_match}</span></a></span>"}
         end)
 
     {subs, uuid_text}
index bd8844458c66353ca5338ea66c756f29f9a0a58a..7040f1c276d312c29bcb5cd379537d2b5ee80b57 100644 (file)
@@ -150,7 +150,7 @@ defmodule Pleroma.FormatterTest do
           archaeme.id
         }' class='u-url mention' href='#{"https://archeme/@archa_eme_"}'>@<span>archa_eme_</span></a></span>, that is @daggsy. Also hello <span class='h-card'><a data-user='#{
           archaeme_remote.id
-        }' class='u-url mention' href='#{archaeme_remote.ap_id}'>@<span>archaeme</span></a></span>"
+        }' class='u-url mention' href='#{archaeme_remote.ap_id}'>@<span>archaeme@archae.me</span></a></span>"
 
       assert expected_text == Formatter.finalize({subs, text})
     end
@@ -168,7 +168,7 @@ defmodule Pleroma.FormatterTest do
       Enum.each(subs, fn {uuid, _} -> assert String.contains?(text, uuid) end)
 
       expected_text =
-        "<span class='h-card'><a data-user='#{mike.id}' class='u-url mention' href='#{mike.ap_id}'>@<span>mike</span></a></span> test"
+        "<span class='h-card'><a data-user='#{mike.id}' class='u-url mention' href='#{mike.ap_id}'>@<span>mike@osada.macgirvin.com</span></a></span> test"
 
       assert expected_text == Formatter.finalize({subs, text})
     end
index 5f7481eb6bb2964d19a56ecdcef692050b47dbe5..b8f1afa76fce4603398c38ead46342ff9c2f84d9 100644 (file)
@@ -12,7 +12,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
   import Pleroma.Factory
 
   setup do
-    user = insert(:user, bio: "<span>Here's some html</span>")
+    user = insert(:user, bio: "<span>Here's some html,</span> @mention@domain.com")
     [user: user]
   end