2017-03-20 21:30:18 +01:00
|
|
|
defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenter do
|
|
|
|
use Pleroma.Web.TwitterAPI.Representers.BaseRepresenter
|
2017-03-28 14:40:09 +02:00
|
|
|
|
2017-03-23 15:51:34 +01:00
|
|
|
alias Pleroma.User
|
|
|
|
|
2017-03-28 14:40:09 +02:00
|
|
|
def to_map(user, opts) do
|
2017-04-17 14:12:36 +02:00
|
|
|
image = User.avatar_url(user)
|
2017-03-23 15:51:34 +01:00
|
|
|
following = if opts[:for] do
|
|
|
|
User.following?(opts[:for], user)
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2017-04-30 10:04:54 +02:00
|
|
|
user_info = User.get_cached_user_info(user)
|
2017-04-21 00:51:09 +02:00
|
|
|
|
2017-03-20 21:30:18 +01:00
|
|
|
map = %{
|
|
|
|
"id" => user.id,
|
|
|
|
"name" => user.name,
|
|
|
|
"screen_name" => user.nickname,
|
|
|
|
"description" => user.bio,
|
2017-03-23 15:51:34 +01:00
|
|
|
"following" => following,
|
2017-03-20 21:30:18 +01:00
|
|
|
# Fake fields
|
|
|
|
"favourites_count" => 0,
|
2017-04-21 00:51:09 +02:00
|
|
|
"statuses_count" => user_info[:note_count],
|
|
|
|
"friends_count" => user_info[:following_count],
|
|
|
|
"followers_count" => user_info[:follower_count],
|
2017-03-20 21:30:18 +01:00
|
|
|
"profile_image_url" => image,
|
|
|
|
"profile_image_url_https" => image,
|
|
|
|
"profile_image_url_profile_size" => image,
|
|
|
|
"profile_image_url_original" => image,
|
|
|
|
"rights" => %{}
|
|
|
|
}
|
|
|
|
|
|
|
|
map
|
|
|
|
end
|
|
|
|
end
|