Web.TwitterAPI.UserView: Add rights.admin
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sun, 23 Dec 2018 17:31:37 +0000 (18:31 +0100)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 28 Dec 2018 16:38:32 +0000 (17:38 +0100)
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
lib/pleroma/web/twitter_api/views/user_view.ex
test/web/twitter_api/views/user_view_test.exs

index 22715bb76bd37dede87f1dbe0c259a15341e6685..a4b17e4f815c0fc93627409d0943bd733a2319c0 100644 (file)
@@ -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}",
index 6e489624f4c721a61a45673ad03bda94014527f7..c04d143c83da5c5acbefb7a573761300bf58f2de 100644 (file)
@@ -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],
index 32e9466e1784128d7968c0073dc7918e39dd574e..5f7481eb6bb2964d19a56ecdcef692050b47dbe5 100644 (file)
@@ -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,