TwitterAPI: profile update with emoji_map
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 22 Feb 2019 23:09:11 +0000 (00:09 +0100)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 3 May 2019 14:30:24 +0000 (16:30 +0200)
lib/pleroma/web/twitter_api/twitter_api_controller.ex
lib/pleroma/web/twitter_api/views/user_view.ex

index 261cc4462443d5ba82c5fe12bd0174a205ff917b..ef7b6fe659bd0bcee72cd9f93972cd505b37392f 100644 (file)
@@ -654,11 +654,17 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
 
   defp parse_profile_bio(user, params) do
     if bio = params["description"] do
+      emojis_text = (params["description"] || "") <> " " <> (params["name"] || "")
+
+      emojis =
+        ((user.info.emoji || []) ++ Formatter.get_emoji_map(emojis_text))
+        |> Enum.dedup()
+
       user_info =
         user.info
         |> Map.put(
-          "emojis",
-          Formatter.get_emoji_map(params["description"])
+          "emoji",
+          emojis
         )
 
       params
index 6857055c95bd358f4aae08008c9d389459eba49f..f0a4ddbd3be1964eeb2116682bb20e87da4387d5 100644 (file)
@@ -69,6 +69,11 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
 
     emoji = Enum.dedup(emoji ++ user.info.emoji)
 
+    description_html =
+      (user.bio || "")
+      |> HTML.filter_tags(User.html_filter_policy(for_user))
+      |> Formatter.emojify(emoji)
+
     # ``fields`` is an array of mastodon profile field, containing ``{"name": "…", "value": "…"}``.
     # For example: [{"name": "Pronoun", "value": "she/her"}, …]
     fields =
@@ -80,7 +85,7 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
       %{
         "created_at" => user.inserted_at |> Utils.format_naive_asctime(),
         "description" => HTML.strip_tags((user.bio || "") |> String.replace("<br>", "\n")),
-        "description_html" => HTML.filter_tags(user.bio, User.html_filter_policy(for_user)),
+        "description_html" => description_html,
         "favourites_count" => 0,
         "followers_count" => user_info[:follower_count],
         "following" => following,