From b43d630f307110b5fa552c28c9fa0ebae09e85f2 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sun, 23 Dec 2018 18:31:37 +0100 Subject: [PATCH] Web.TwitterAPI.UserView: Add rights.admin --- .../mastodon_api/mastodon_api_controller.ex | 3 ++- .../web/twitter_api/views/user_view.ex | 3 ++- test/web/twitter_api/views/user_view_test.exs | 19 +++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 22715bb76..a4b17e4f8 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -966,7 +966,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do max_toot_chars: limit }, rights: %{ - delete_others_notice: !!user.info.is_moderator + delete_others_notice: !!user.info.is_moderator, + admin: !!user.info.is_admin }, compose: %{ me: "#{user.id}", diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex index 6e489624f..c04d143c8 100644 --- a/lib/pleroma/web/twitter_api/views/user_view.ex +++ b/lib/pleroma/web/twitter_api/views/user_view.ex @@ -70,7 +70,8 @@ defmodule Pleroma.Web.TwitterAPI.UserView do "profile_image_url_profile_size" => image, "profile_image_url_original" => image, "rights" => %{ - "delete_others_notice" => !!user.info.is_moderator + "delete_others_notice" => !!user.info.is_moderator, + "admin" => !!user.info.is_admin }, "screen_name" => user.nickname, "statuses_count" => user_info[:note_count], diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs index 32e9466e1..5f7481eb6 100644 --- a/test/web/twitter_api/views/user_view_test.exs +++ b/test/web/twitter_api/views/user_view_test.exs @@ -90,7 +90,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "follows_you" => false, "statusnet_blocking" => false, "rights" => %{ - "delete_others_notice" => false + "delete_others_notice" => false, + "admin" => false }, "statusnet_profile_url" => user.ap_id, "cover_photo" => banner, @@ -135,7 +136,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "follows_you" => false, "statusnet_blocking" => false, "rights" => %{ - "delete_others_notice" => false + "delete_others_notice" => false, + "admin" => false }, "statusnet_profile_url" => user.ap_id, "cover_photo" => banner, @@ -181,7 +183,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "follows_you" => true, "statusnet_blocking" => false, "rights" => %{ - "delete_others_notice" => false + "delete_others_notice" => false, + "admin" => false }, "statusnet_profile_url" => follower.ap_id, "cover_photo" => banner, @@ -207,6 +210,13 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do assert represented["rights"]["delete_others_notice"] end + test "a user that is a admin" do + user = insert(:user, %{info: %{is_admin: true}}) + represented = UserView.render("show.json", %{user: user, for: user}) + + assert represented["rights"]["admin"] + end + test "A blocked user for the blocker" do user = insert(:user) blocker = insert(:user) @@ -234,7 +244,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "follows_you" => false, "statusnet_blocking" => true, "rights" => %{ - "delete_others_notice" => false + "delete_others_notice" => false, + "admin" => false }, "statusnet_profile_url" => user.ap_id, "cover_photo" => banner, -- 2.45.2