Fix `rights` in TwitterAPI's user entity being present only for
authorrinpatch <rinpatch@sdf.org>
Sun, 28 Apr 2019 16:42:43 +0000 (19:42 +0300)
committerrinpatch <rinpatch@sdf.org>
Sun, 28 Apr 2019 16:42:43 +0000 (19:42 +0300)
Admins/Moderators

In !1093 I reused `maybe_with_role` for `rights` object, however I
missed that `maybe_with_role` is called only for admins/moderators.

lib/pleroma/web/twitter_api/views/user_view.ex
test/web/twitter_api/views/user_view_test.exs

index 39b3f21c0f6ad65ec2e466d863f3d8804666ba72..ea015b8f05549b19a4a5721af4b1093349a654a0 100644 (file)
@@ -116,12 +116,7 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
           |> maybe_with_activation_status(user, for_user)
       }
       |> maybe_with_user_settings(user, for_user)
-
-    data =
-      if(user.info.is_admin || user.info.is_moderator,
-        do: maybe_with_role(data, user, for_user),
-        else: data
-      )
+      |> maybe_with_role(user, for_user)
 
     if assigns[:token] do
       Map.put(data, "token", token_string(assigns[:token]))
index 2f9b2af0127a918af8c4831378b4fc557214958d..c99dbddeb355630cb4819ec23b26f0130fa0452f 100644 (file)
@@ -100,7 +100,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "pleroma" => %{
         "confirmation_pending" => false,
         "tags" => []
-      }
+      },
+      "rights" => %{"admin" => false, "delete_others_notice" => false},
+      "role" => "member"
     }
 
     assert represented == UserView.render("show.json", %{user: user})
@@ -151,7 +153,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "pleroma" => %{
         "confirmation_pending" => false,
         "tags" => []
-      }
+      },
+      "rights" => %{"admin" => false, "delete_others_notice" => false},
+      "role" => "member"
     }
 
     assert represented == UserView.render("show.json", %{user: user, for: follower})
@@ -194,7 +198,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "pleroma" => %{
         "confirmation_pending" => false,
         "tags" => []
-      }
+      },
+      "rights" => %{"admin" => false, "delete_others_notice" => false},
+      "role" => "member"
     }
 
     assert represented == UserView.render("show.json", %{user: follower, for: user})
@@ -274,7 +280,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
       "pleroma" => %{
         "confirmation_pending" => false,
         "tags" => []
-      }
+      },
+      "rights" => %{"admin" => false, "delete_others_notice" => false},
+      "role" => "member"
     }
 
     blocker = User.get_cached_by_id(blocker.id)