From 2bfae25a1ff735499e15cb431314503f34097a6b Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Thu, 17 Jan 2019 18:03:49 +0300 Subject: [PATCH] [#491] Made user bio preserve full nicknames (nick@host). --- lib/pleroma/formatter.ex | 7 +++---- test/formatter_test.exs | 4 ++-- test/web/twitter_api/views/user_view_test.exs | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index 4149265a2..024c6e117 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -142,12 +142,11 @@ def add_user_links({subs, text}, mentions) do ap_id end - short_match = String.split(match, "@") |> tl() |> hd() + full_match = String.trim_leading(match, "@") {uuid, - "@#{ - short_match - }"} + "" <> + "@#{full_match}"} end) {subs, uuid_text} diff --git a/test/formatter_test.exs b/test/formatter_test.exs index bd8844458..7040f1c27 100644 --- a/test/formatter_test.exs +++ b/test/formatter_test.exs @@ -150,7 +150,7 @@ test "gives a replacement for user links" do archaeme.id }' class='u-url mention' href='#{"https://archeme/@archa_eme_"}'>@archa_eme_, that is @daggsy. Also hello @archaeme" + }' class='u-url mention' href='#{archaeme_remote.ap_id}'>@archaeme@archae.me" assert expected_text == Formatter.finalize({subs, text}) 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) expected_text = - "@mike test" + "@mike@osada.macgirvin.com test" assert expected_text == Formatter.finalize({subs, text}) end diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs index 5f7481eb6..b8f1afa76 100644 --- a/test/web/twitter_api/views/user_view_test.exs +++ b/test/web/twitter_api/views/user_view_test.exs @@ -12,7 +12,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do import Pleroma.Factory setup do - user = insert(:user, bio: "Here's some html") + user = insert(:user, bio: "Here's some html, @mention@domain.com") [user: user] end