Add moderator function.
authorlain <lain@soykaf.club>
Tue, 20 Feb 2018 17:44:50 +0000 (18:44 +0100)
committerlain <lain@soykaf.club>
Tue, 20 Feb 2018 17:44:50 +0000 (18:44 +0100)
lib/pleroma/web/twitter_api/views/user_view.ex
test/web/twitter_api/views/user_view_test.exs

index f49bcc0fb1e6fb90e20d17d7d9aa16448f1df870..6fb07f052692e12b022ee7820b6780d428ab572d 100644 (file)
@@ -41,7 +41,9 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
       "profile_image_url_https" => image,
       "profile_image_url_profile_size" => image,
       "profile_image_url_original" => image,
-      "rights" => %{},
+      "rights" => %{
+        "delete_others_notice" => !!user.info["is_moderator"]
+      },
       "screen_name" => user.nickname,
       "statuses_count" => user_info[:note_count],
       "statusnet_profile_url" => user.ap_id,
index a687020f0138377e41ad41a65865d022c3f3f260..9e0a8a532e8dbcc051006db019df76b704fb8763 100644 (file)
@@ -53,7 +53,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "following" => false,
       "follows_you" => false,
       "statusnet_blocking" => false,
-      "rights" => %{},
+      "rights" => %{
+        "delete_others_notice" => false
+      },
       "statusnet_profile_url" => user.ap_id,
       "cover_photo" => banner,
       "background_image" => nil,
@@ -86,7 +88,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "following" => true,
       "follows_you" => false,
       "statusnet_blocking" => false,
-      "rights" => %{},
+      "rights" => %{
+        "delete_others_notice" => false
+      },
       "statusnet_profile_url" => user.ap_id,
       "cover_photo" => banner,
       "background_image" => nil,
@@ -120,7 +124,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "following" => false,
       "follows_you" => true,
       "statusnet_blocking" => false,
-      "rights" => %{},
+      "rights" => %{
+        "delete_others_notice" => false
+      },
       "statusnet_profile_url" => follower.ap_id,
       "cover_photo" => banner,
       "background_image" => nil,
@@ -130,6 +136,13 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
     assert represented == UserView.render("show.json", %{user: follower, for: user})
   end
 
+  test "a user that is a moderator" do
+    user = insert(:user, %{info: %{"is_moderator" => true}})
+    represented = UserView.render("show.json", %{user: user, for: user})
+
+    assert represented["rights"]["delete_others_notice"]
+  end
+
   test "A blocked user for the blocker" do
     user = insert(:user)
     blocker = insert(:user)
@@ -154,7 +167,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "following" => false,
       "follows_you" => false,
       "statusnet_blocking" => true,
-      "rights" => %{},
+      "rights" => %{
+        "delete_others_notice" => false
+      },
       "statusnet_profile_url" => user.ap_id,
       "cover_photo" => banner,
       "background_image" => nil,