2017-03-20 14:30:18 -06:00
|
|
|
defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenter do
|
|
|
|
use Pleroma.Web.TwitterAPI.Representers.BaseRepresenter
|
2017-03-28 06:40:09 -06:00
|
|
|
|
2017-03-23 08:51:34 -06:00
|
|
|
alias Pleroma.User
|
|
|
|
|
2017-03-28 06:40:09 -06:00
|
|
|
def to_map(user, opts) do
|
2017-04-17 06:12:36 -06:00
|
|
|
image = User.avatar_url(user)
|
2017-03-23 08:51:34 -06:00
|
|
|
following = if opts[:for] do
|
|
|
|
User.following?(opts[:for], user)
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2017-04-30 02:04:54 -06:00
|
|
|
user_info = User.get_cached_user_info(user)
|
2017-06-05 07:47:37 -06:00
|
|
|
created_at = user.inserted_at |> DateTime.from_naive!("Etc/UTC") |> format_asctime
|
2017-04-20 16:51:09 -06:00
|
|
|
|
2017-03-20 14:30:18 -06:00
|
|
|
map = %{
|
|
|
|
"id" => user.id,
|
|
|
|
"name" => user.name,
|
|
|
|
"screen_name" => user.nickname,
|
2017-06-18 05:17:35 -06:00
|
|
|
"description" => HtmlSanitizeEx.strip_tags(user.bio),
|
2017-03-23 08:51:34 -06:00
|
|
|
"following" => following,
|
2017-06-05 07:47:37 -06:00
|
|
|
"created_at" => created_at,
|
2017-03-20 14:30:18 -06:00
|
|
|
# Fake fields
|
|
|
|
"favourites_count" => 0,
|
2017-04-20 16:51:09 -06:00
|
|
|
"statuses_count" => user_info[:note_count],
|
|
|
|
"friends_count" => user_info[:following_count],
|
|
|
|
"followers_count" => user_info[:follower_count],
|
2017-03-20 14:30:18 -06:00
|
|
|
"profile_image_url" => image,
|
|
|
|
"profile_image_url_https" => image,
|
|
|
|
"profile_image_url_profile_size" => image,
|
|
|
|
"profile_image_url_original" => image,
|
2017-05-02 06:36:04 -06:00
|
|
|
"rights" => %{},
|
|
|
|
"statusnet_profile_url" => user.ap_id
|
2017-03-20 14:30:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
map
|
|
|
|
end
|
|
|
|
end
|