diff options
author | Maxim Filippov <colixer@gmail.com> | 2018-12-02 22:03:53 +0300 |
---|---|---|
committer | Maxim Filippov <colixer@gmail.com> | 2018-12-02 22:03:53 +0300 |
commit | ce98d5eb9b4d9c5a09b91a9d4d13bb48ba2b8453 (patch) | |
tree | 248211f13a9dd265a04998ceb1a2fb920f80d54e /lib/pleroma/user.ex | |
parent | 371d96b1da85960dafea9665b8bc32ba553b1555 (diff) | |
download | pleroma-ce98d5eb9b4d9c5a09b91a9d4d13bb48ba2b8453.tar.gz |
Parse user's bio on register
Diffstat (limited to 'lib/pleroma/user.ex')
-rw-r--r-- | lib/pleroma/user.ex | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 76712b4bf..3bd92c157 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -4,6 +4,8 @@ defmodule Pleroma.User do import Ecto.{Changeset, Query} alias Pleroma.{Repo, User, Object, Web, Activity, Notification} alias Comeonin.Pbkdf2 + alias Pleroma.Formatter + alias Pleroma.Web.CommonAPI.Utils, as: CommonUtils alias Pleroma.Web.{OStatus, Websub, OAuth} alias Pleroma.Web.ActivityPub.{Utils, ActivityPub} @@ -802,4 +804,18 @@ defmodule Pleroma.User do :error end end + + def parse_bio(bio, user \\ %User{info: %{source_data: %{}}}) do + mentions = Formatter.parse_mentions(bio) + tags = Formatter.parse_tags(bio) + + 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) + + CommonUtils.format_input(bio, mentions, tags, "text/plain") |> Formatter.emojify(emoji) + end end |