projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Revert "Revert "Add remote follow pages.""
[akkoma]
/
lib
/
pleroma
/
web
/
twitter_api
/
views
/
user_view.ex
diff --git
a/lib/pleroma/web/twitter_api/views/user_view.ex
b/lib/pleroma/web/twitter_api/views/user_view.ex
index 6c5676c04122018ed1675012b15b743dfb6b79de..1b995f42fea3322a901febd16750214338ef4264 100644
(file)
--- a/
lib/pleroma/web/twitter_api/views/user_view.ex
+++ b/
lib/pleroma/web/twitter_api/views/user_view.ex
@@
-2,6
+2,7
@@
defmodule Pleroma.Web.TwitterAPI.UserView do
use Pleroma.Web, :view
alias Pleroma.User
alias Pleroma.Web.CommonAPI.Utils
use Pleroma.Web, :view
alias Pleroma.User
alias Pleroma.Web.CommonAPI.Utils
+ alias Pleroma.Web.MediaProxy
def render("show.json", %{user: user = %User{}} = assigns) do
render_one(user, Pleroma.Web.TwitterAPI.UserView, "user.json", assigns)
def render("show.json", %{user: user = %User{}} = assigns) do
render_one(user, Pleroma.Web.TwitterAPI.UserView, "user.json", assigns)
@@
-11,11
+12,8
@@
defmodule Pleroma.Web.TwitterAPI.UserView do
render_many(users, Pleroma.Web.TwitterAPI.UserView, "user.json", for: user)
end
render_many(users, Pleroma.Web.TwitterAPI.UserView, "user.json", for: user)
end
- defp image_url(%{"url" => [ %{ "href" => href } | t ]}), do: href
- defp image_url(_), do: nil
-
def render("user.json", %{user: user = %User{}} = assigns) do
def render("user.json", %{user: user = %User{}} = assigns) do
- image = User.avatar_url(user)
+ image = User.avatar_url(user)
|> MediaProxy.url()
{following, follows_you, statusnet_blocking} = if assigns[:for] do
{
User.following?(assigns[:for], user),
{following, follows_you, statusnet_blocking} = if assigns[:for] do
{
User.following?(assigns[:for], user),
@@
-28,7
+26,7
@@
defmodule Pleroma.Web.TwitterAPI.UserView do
user_info = User.get_cached_user_info(user)
user_info = User.get_cached_user_info(user)
- %{
+
data =
%{
"created_at" => user.inserted_at |> Utils.format_naive_asctime,
"description" => HtmlSanitizeEx.strip_tags(user.bio),
"favourites_count" => 0,
"created_at" => user.inserted_at |> Utils.format_naive_asctime,
"description" => HtmlSanitizeEx.strip_tags(user.bio),
"favourites_count" => 0,
@@
-47,9
+45,15
@@
defmodule Pleroma.Web.TwitterAPI.UserView do
"screen_name" => user.nickname,
"statuses_count" => user_info[:note_count],
"statusnet_profile_url" => user.ap_id,
"screen_name" => user.nickname,
"statuses_count" => user_info[:note_count],
"statusnet_profile_url" => user.ap_id,
- "cover_photo" =>
image_url(user.info["banner"]
),
- "background_image" => image_url(user.info["background"])
+ "cover_photo" =>
User.banner_url(user) |> MediaProxy.url(
),
+ "background_image" => image_url(user.info["background"])
|> MediaProxy.url(),
}
}
+
+ if assigns[:token] do
+ Map.put(data, "token", assigns[:token])
+ else
+ data
+ end
end
def render("short.json", %{user: %User{
end
def render("short.json", %{user: %User{
@@
-63,4
+67,7
@@
defmodule Pleroma.Web.TwitterAPI.UserView do
"screen_name" => nickname
}
end
"screen_name" => nickname
}
end
+
+ defp image_url(%{"url" => [ %{ "href" => href } | _ ]}), do: href
+ defp image_url(_), do: nil
end
end