Merge branch '491_full_mentions_in_user_bio' into 'develop'

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

Closes #491

See merge request pleroma/pleroma!676
This commit is contained in:
kaniini 2019-01-19 07:36:58 +00:00
commit 651ce1c97b
5 changed files with 45 additions and 15 deletions

View file

@ -447,8 +447,7 @@ defmodule Pleroma.User do
def get_by_nickname(nickname) do
Repo.get_by(User, nickname: nickname) ||
if Regex.match?(~r(@#{Pleroma.Web.Endpoint.host()})i, nickname) do
[local_nickname, _] = String.split(nickname, "@")
Repo.get_by(User, nickname: local_nickname)
Repo.get_by(User, nickname: local_nickname(nickname))
end
end
@ -997,7 +996,7 @@ defmodule Pleroma.User do
end)
bio
|> CommonUtils.format_input(mentions, tags, "text/plain")
|> CommonUtils.format_input(mentions, tags, "text/plain", user_links: [format: :full])
|> Formatter.emojify(emoji)
end
@ -1048,6 +1047,16 @@ defmodule Pleroma.User do
end
end
def local_nickname(nickname_or_mention) do
nickname_or_mention
|> full_nickname()
|> String.split("@")
|> hd()
end
def full_nickname(nickname_or_mention),
do: String.trim_leading(nickname_or_mention, "@")
def error_user(ap_id) do
%User{
name: ap_id,