forked from mirrors/akkoma
TwitterAPI user view: add screen_name_html and description_html.
This commit is contained in:
parent
c2d1a5e9c4
commit
cee63ad3f7
2 changed files with 21 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
defmodule Pleroma.Web.TwitterAPI.UserView do
|
defmodule Pleroma.Web.TwitterAPI.UserView do
|
||||||
use Pleroma.Web, :view
|
use Pleroma.Web, :view
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
alias Pleroma.Formatter
|
||||||
alias Pleroma.Web.CommonAPI.Utils
|
alias Pleroma.Web.CommonAPI.Utils
|
||||||
alias Pleroma.Web.MediaProxy
|
alias Pleroma.Web.MediaProxy
|
||||||
|
|
||||||
|
@ -28,9 +29,19 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
|
||||||
|
|
||||||
user_info = User.get_cached_user_info(user)
|
user_info = User.get_cached_user_info(user)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
bio = HtmlSanitizeEx.strip_tags(user.bio)
|
||||||
|
|
||||||
data = %{
|
data = %{
|
||||||
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
|
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
|
||||||
"description" => HtmlSanitizeEx.strip_tags(user.bio),
|
"description" => bio,
|
||||||
|
"description_html" => bio |> Formatter.emojify(emoji),
|
||||||
"favourites_count" => 0,
|
"favourites_count" => 0,
|
||||||
"followers_count" => user_info[:follower_count],
|
"followers_count" => user_info[:follower_count],
|
||||||
"following" => following,
|
"following" => following,
|
||||||
|
@ -47,6 +58,7 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
|
||||||
"delete_others_notice" => !!user.info["is_moderator"]
|
"delete_others_notice" => !!user.info["is_moderator"]
|
||||||
},
|
},
|
||||||
"screen_name" => user.nickname,
|
"screen_name" => user.nickname,
|
||||||
|
"screen_name_html" => Formatter.emojify(user.nickname, emoji),
|
||||||
"statuses_count" => user_info[:note_count],
|
"statuses_count" => user_info[:note_count],
|
||||||
"statusnet_profile_url" => user.ap_id,
|
"statusnet_profile_url" => user.ap_id,
|
||||||
"cover_photo" => User.banner_url(user) |> MediaProxy.url(),
|
"cover_photo" => User.banner_url(user) |> MediaProxy.url(),
|
||||||
|
|
|
@ -40,7 +40,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
||||||
"id" => user.id,
|
"id" => user.id,
|
||||||
"name" => user.name,
|
"name" => user.name,
|
||||||
"screen_name" => user.nickname,
|
"screen_name" => user.nickname,
|
||||||
|
"screen_name_html" => user.nickname,
|
||||||
"description" => HtmlSanitizeEx.strip_tags(user.bio),
|
"description" => HtmlSanitizeEx.strip_tags(user.bio),
|
||||||
|
"description_html" => HtmlSanitizeEx.strip_tags(user.bio),
|
||||||
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
|
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
|
||||||
"favourites_count" => 0,
|
"favourites_count" => 0,
|
||||||
"statuses_count" => 1,
|
"statuses_count" => 1,
|
||||||
|
@ -77,7 +79,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
||||||
"id" => user.id,
|
"id" => user.id,
|
||||||
"name" => user.name,
|
"name" => user.name,
|
||||||
"screen_name" => user.nickname,
|
"screen_name" => user.nickname,
|
||||||
|
"screen_name_html" => user.nickname,
|
||||||
"description" => HtmlSanitizeEx.strip_tags(user.bio),
|
"description" => HtmlSanitizeEx.strip_tags(user.bio),
|
||||||
|
"description_html" => HtmlSanitizeEx.strip_tags(user.bio),
|
||||||
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
|
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
|
||||||
"favourites_count" => 0,
|
"favourites_count" => 0,
|
||||||
"statuses_count" => 0,
|
"statuses_count" => 0,
|
||||||
|
@ -115,7 +119,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
||||||
"id" => follower.id,
|
"id" => follower.id,
|
||||||
"name" => follower.name,
|
"name" => follower.name,
|
||||||
"screen_name" => follower.nickname,
|
"screen_name" => follower.nickname,
|
||||||
|
"screen_name_html" => follower.nickname,
|
||||||
"description" => HtmlSanitizeEx.strip_tags(follower.bio),
|
"description" => HtmlSanitizeEx.strip_tags(follower.bio),
|
||||||
|
"description_html" => HtmlSanitizeEx.strip_tags(follower.bio),
|
||||||
"created_at" => follower.inserted_at |> Utils.format_naive_asctime(),
|
"created_at" => follower.inserted_at |> Utils.format_naive_asctime(),
|
||||||
"favourites_count" => 0,
|
"favourites_count" => 0,
|
||||||
"statuses_count" => 0,
|
"statuses_count" => 0,
|
||||||
|
@ -160,7 +166,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
||||||
"id" => user.id,
|
"id" => user.id,
|
||||||
"name" => user.name,
|
"name" => user.name,
|
||||||
"screen_name" => user.nickname,
|
"screen_name" => user.nickname,
|
||||||
|
"screen_name_html" => user.nickname,
|
||||||
"description" => HtmlSanitizeEx.strip_tags(user.bio),
|
"description" => HtmlSanitizeEx.strip_tags(user.bio),
|
||||||
|
"description_html" => HtmlSanitizeEx.strip_tags(user.bio),
|
||||||
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
|
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
|
||||||
"favourites_count" => 0,
|
"favourites_count" => 0,
|
||||||
"statuses_count" => 0,
|
"statuses_count" => 0,
|
||||||
|
|
Loading…
Reference in a new issue