aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMaxim Filippov <colixer@gmail.com>2019-02-28 17:43:09 +0300
committerMaxim Filippov <colixer@gmail.com>2019-02-28 17:43:09 +0300
commit72b7a0797ec42a021f4f8f50dce859fb0f12bf75 (patch)
tree20f2ed98c7a970ee00582bf67d98b003178aa2ef /lib
parent2883f75a3a25599c6217460133578cddcd34ebb4 (diff)
downloadpleroma-72b7a0797ec42a021f4f8f50dce859fb0f12bf75.tar.gz
Use Mastodon API views in Admin API
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/admin_api/admin_api_controller.ex6
-rw-r--r--lib/pleroma/web/mastodon_api/views/admin/account_view.ex25
-rw-r--r--lib/pleroma/web/twitter_api/views/user_view.ex17
3 files changed, 28 insertions, 20 deletions
diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex
index d75b7e7e7..d8e3d57e1 100644
--- a/lib/pleroma/web/admin_api/admin_api_controller.ex
+++ b/lib/pleroma/web/admin_api/admin_api_controller.ex
@@ -8,7 +8,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
use Pleroma.Web, :controller
alias Pleroma.User
alias Pleroma.Web.ActivityPub.Relay
- alias Pleroma.Web.TwitterAPI.UserView
+ alias Pleroma.Web.MastodonAPI.Admin.AccountView
import Pleroma.Web.ControllerHelper, only: [json_response: 3]
@@ -50,7 +50,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
{:ok, updated_user} = User.deactivate(user, !user.info.deactivated)
conn
- |> json(UserView.render("show_for_admin.json", %{user: updated_user}))
+ |> json(AccountView.render("show.json", %{user: updated_user}))
end
def tag_users(conn, %{"nicknames" => nicknames, "tags" => tags}) do
@@ -70,7 +70,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
do:
conn
|> json(
- UserView.render("index_for_admin.json", %{
+ AccountView.render("index.json", %{
users: users,
count: count,
page_size: @users_page_size
diff --git a/lib/pleroma/web/mastodon_api/views/admin/account_view.ex b/lib/pleroma/web/mastodon_api/views/admin/account_view.ex
new file mode 100644
index 000000000..74ca13564
--- /dev/null
+++ b/lib/pleroma/web/mastodon_api/views/admin/account_view.ex
@@ -0,0 +1,25 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.MastodonAPI.Admin.AccountView do
+ use Pleroma.Web, :view
+
+ alias Pleroma.Web.MastodonAPI.Admin.AccountView
+
+ def render("index.json", %{users: users, count: count, page_size: page_size}) do
+ %{
+ users: render_many(users, AccountView, "show.json", as: :user),
+ count: count,
+ page_size: page_size
+ }
+ end
+
+ def render("show.json", %{user: user}) do
+ %{
+ "id" => user.id,
+ "nickname" => user.nickname,
+ "deactivated" => user.info.deactivated
+ }
+ end
+end
diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex
index e8514d3ba..df7384476 100644
--- a/lib/pleroma/web/twitter_api/views/user_view.ex
+++ b/lib/pleroma/web/twitter_api/views/user_view.ex
@@ -9,7 +9,6 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
alias Pleroma.User
alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.MediaProxy
- alias Pleroma.Web.TwitterAPI.UserView
def render("show.json", %{user: user = %User{}} = assigns) do
render_one(user, Pleroma.Web.TwitterAPI.UserView, "user.json", assigns)
@@ -27,22 +26,6 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
else: %{}
end
- def render("index_for_admin.json", %{users: users, count: count, page_size: page_size} = opts) do
- %{
- users: render_many(users, UserView, "show_for_admin.json", opts),
- count: count,
- page_size: page_size
- }
- end
-
- def render("show_for_admin.json", %{user: user}) do
- %{
- "id" => user.id,
- "nickname" => user.nickname,
- "deactivated" => user.info.deactivated
- }
- end
-
def render("short.json", %{
user: %User{
nickname: nickname,