forked from AkkomaGang/akkoma
Pleroma.User: remove emojify on parse_bio
This commit is contained in:
parent
85b5c60694
commit
d70af32127
3 changed files with 11 additions and 14 deletions
|
@ -11,7 +11,6 @@ defmodule Pleroma.User do
|
||||||
alias Comeonin.Pbkdf2
|
alias Comeonin.Pbkdf2
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
alias Pleroma.Bookmark
|
alias Pleroma.Bookmark
|
||||||
alias Pleroma.Formatter
|
|
||||||
alias Pleroma.Notification
|
alias Pleroma.Notification
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.Registration
|
alias Pleroma.Registration
|
||||||
|
@ -1331,18 +1330,15 @@ def wait_and_refresh(timeout, %User{} = a, %User{} = b) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_bio(bio, user \\ %User{info: %{source_data: %{}}})
|
def parse_bio(bio) when is_binary(bio) and bio != "" do
|
||||||
def parse_bio(nil, _user), do: ""
|
bio
|
||||||
def parse_bio(bio, _user) when bio == "", do: bio
|
|> CommonUtils.format_input("text/plain", mentions_format: :full)
|
||||||
|
|> elem(0)
|
||||||
|
end
|
||||||
|
|
||||||
def parse_bio(bio, user) do
|
def parse_bio(_), do: ""
|
||||||
emoji =
|
|
||||||
(user.info.source_data["tag"] || [])
|
|
||||||
|> Enum.filter(fn %{"type" => t} -> t == "Emoji" end)
|
|
||||||
|> Enum.map(fn %{"icon" => %{"url" => url}, "name" => name} ->
|
|
||||||
{String.trim(name, ":"), url}
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
def parse_bio(bio, user) when is_binary(bio) and bio != "" do
|
||||||
# TODO: get profile URLs other than user.ap_id
|
# TODO: get profile URLs other than user.ap_id
|
||||||
profile_urls = [user.ap_id]
|
profile_urls = [user.ap_id]
|
||||||
|
|
||||||
|
@ -1352,9 +1348,10 @@ def parse_bio(bio, user) do
|
||||||
rel: &RelMe.maybe_put_rel_me(&1, profile_urls)
|
rel: &RelMe.maybe_put_rel_me(&1, profile_urls)
|
||||||
)
|
)
|
||||||
|> elem(0)
|
|> elem(0)
|
||||||
|> Formatter.emojify(emoji)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def parse_bio(_, _), do: ""
|
||||||
|
|
||||||
def tag(user_identifiers, tags) when is_list(user_identifiers) do
|
def tag(user_identifiers, tags) when is_list(user_identifiers) do
|
||||||
Repo.transaction(fn ->
|
Repo.transaction(fn ->
|
||||||
for user_identifier <- user_identifiers, do: tag(user_identifier, tags)
|
for user_identifier <- user_identifiers, do: tag(user_identifier, tags)
|
||||||
|
|
|
@ -86,7 +86,7 @@ def update_credentials(%{assigns: %{user: user}} = conn, params) do
|
||||||
user_params =
|
user_params =
|
||||||
%{}
|
%{}
|
||||||
|> add_if_present(params, "display_name", :name)
|
|> add_if_present(params, "display_name", :name)
|
||||||
|> add_if_present(params, "note", :bio, fn value -> {:ok, User.parse_bio(value)} end)
|
|> add_if_present(params, "note", :bio, fn value -> {:ok, User.parse_bio(value, user)} end)
|
||||||
|> add_if_present(params, "avatar", :avatar, fn value ->
|
|> add_if_present(params, "avatar", :avatar, fn value ->
|
||||||
with %Plug.Upload{} <- value,
|
with %Plug.Upload{} <- value,
|
||||||
{:ok, object} <- ActivityPub.upload(value, type: :avatar) do
|
{:ok, object} <- ActivityPub.upload(value, type: :avatar) do
|
||||||
|
|
|
@ -1103,7 +1103,7 @@ test "preserves hosts in user links text" do
|
||||||
expected_text =
|
expected_text =
|
||||||
"A.k.a. <span class='h-card'><a data-user='#{remote_user.id}' class='u-url mention' href='#{
|
"A.k.a. <span class='h-card'><a data-user='#{remote_user.id}' class='u-url mention' href='#{
|
||||||
remote_user.ap_id
|
remote_user.ap_id
|
||||||
}'>" <> "@<span>nick@domain.com</span></a></span>"
|
}'>@<span>nick@domain.com</span></a></span>"
|
||||||
|
|
||||||
assert expected_text == User.parse_bio(bio, user)
|
assert expected_text == User.parse_bio(bio, user)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue