[#491] Made user bio preserve full nicknames (nick@host).

This commit is contained in:
Ivan Tashkinov 2019-01-17 18:03:49 +03:00
parent ce2efd1ee2
commit 2bfae25a1f
3 changed files with 6 additions and 7 deletions

View File

@ -142,12 +142,11 @@ def add_user_links({subs, text}, mentions) do
ap_id ap_id
end end
short_match = String.split(match, "@") |> tl() |> hd() full_match = String.trim_leading(match, "@")
{uuid, {uuid,
"<span class='h-card'><a data-user='#{id}' class='u-url mention' href='#{ap_id}'>@<span>#{ "<span class='h-card'><a data-user='#{id}' class='u-url mention' href='#{ap_id}'>" <>
short_match "@<span>#{full_match}</span></a></span>"}
}</span></a></span>"}
end) end)
{subs, uuid_text} {subs, uuid_text}

View File

@ -150,7 +150,7 @@ test "gives a replacement for user links" do
archaeme.id 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='#{ }' 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 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}) assert expected_text == Formatter.finalize({subs, text})
end end
@ -168,7 +168,7 @@ test "gives a replacement for user links when the user is using Osada" do
Enum.each(subs, fn {uuid, _} -> assert String.contains?(text, uuid) end) Enum.each(subs, fn {uuid, _} -> assert String.contains?(text, uuid) end)
expected_text = 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}) assert expected_text == Formatter.finalize({subs, text})
end end

View File

@ -12,7 +12,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
import Pleroma.Factory import Pleroma.Factory
setup do 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] [user: user]
end end