forked from AkkomaGang/akkoma
Merge branch 'features/admin-api-user-views' into 'develop'
User/Account views: Add rights.admin Closes #472 See merge request pleroma/pleroma!589
This commit is contained in:
commit
90e157ef80
3 changed files with 19 additions and 6 deletions
|
@ -964,7 +964,8 @@ def index(%{assigns: %{user: user}} = conn, _params) do
|
||||||
max_toot_chars: limit
|
max_toot_chars: limit
|
||||||
},
|
},
|
||||||
rights: %{
|
rights: %{
|
||||||
delete_others_notice: !!user.info.is_moderator
|
delete_others_notice: !!user.info.is_moderator,
|
||||||
|
admin: !!user.info.is_admin
|
||||||
},
|
},
|
||||||
compose: %{
|
compose: %{
|
||||||
me: "#{user.id}",
|
me: "#{user.id}",
|
||||||
|
|
|
@ -96,7 +96,8 @@ defp do_render("user.json", %{user: user = %User{}} = assigns) do
|
||||||
"profile_image_url_profile_size" => image,
|
"profile_image_url_profile_size" => image,
|
||||||
"profile_image_url_original" => image,
|
"profile_image_url_original" => image,
|
||||||
"rights" => %{
|
"rights" => %{
|
||||||
"delete_others_notice" => !!user.info.is_moderator
|
"delete_others_notice" => !!user.info.is_moderator,
|
||||||
|
"admin" => !!user.info.is_admin
|
||||||
},
|
},
|
||||||
"screen_name" => user.nickname,
|
"screen_name" => user.nickname,
|
||||||
"statuses_count" => user_info[:note_count],
|
"statuses_count" => user_info[:note_count],
|
||||||
|
|
|
@ -90,7 +90,8 @@ test "A user" do
|
||||||
"follows_you" => false,
|
"follows_you" => false,
|
||||||
"statusnet_blocking" => false,
|
"statusnet_blocking" => false,
|
||||||
"rights" => %{
|
"rights" => %{
|
||||||
"delete_others_notice" => false
|
"delete_others_notice" => false,
|
||||||
|
"admin" => false
|
||||||
},
|
},
|
||||||
"statusnet_profile_url" => user.ap_id,
|
"statusnet_profile_url" => user.ap_id,
|
||||||
"cover_photo" => banner,
|
"cover_photo" => banner,
|
||||||
|
@ -135,7 +136,8 @@ test "A user for a given other follower", %{user: user} do
|
||||||
"follows_you" => false,
|
"follows_you" => false,
|
||||||
"statusnet_blocking" => false,
|
"statusnet_blocking" => false,
|
||||||
"rights" => %{
|
"rights" => %{
|
||||||
"delete_others_notice" => false
|
"delete_others_notice" => false,
|
||||||
|
"admin" => false
|
||||||
},
|
},
|
||||||
"statusnet_profile_url" => user.ap_id,
|
"statusnet_profile_url" => user.ap_id,
|
||||||
"cover_photo" => banner,
|
"cover_photo" => banner,
|
||||||
|
@ -181,7 +183,8 @@ test "A user that follows you", %{user: user} do
|
||||||
"follows_you" => true,
|
"follows_you" => true,
|
||||||
"statusnet_blocking" => false,
|
"statusnet_blocking" => false,
|
||||||
"rights" => %{
|
"rights" => %{
|
||||||
"delete_others_notice" => false
|
"delete_others_notice" => false,
|
||||||
|
"admin" => false
|
||||||
},
|
},
|
||||||
"statusnet_profile_url" => follower.ap_id,
|
"statusnet_profile_url" => follower.ap_id,
|
||||||
"cover_photo" => banner,
|
"cover_photo" => banner,
|
||||||
|
@ -207,6 +210,13 @@ test "a user that is a moderator" do
|
||||||
assert represented["rights"]["delete_others_notice"]
|
assert represented["rights"]["delete_others_notice"]
|
||||||
end
|
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
|
test "A blocked user for the blocker" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
blocker = insert(:user)
|
blocker = insert(:user)
|
||||||
|
@ -234,7 +244,8 @@ test "A blocked user for the blocker" do
|
||||||
"follows_you" => false,
|
"follows_you" => false,
|
||||||
"statusnet_blocking" => true,
|
"statusnet_blocking" => true,
|
||||||
"rights" => %{
|
"rights" => %{
|
||||||
"delete_others_notice" => false
|
"delete_others_notice" => false,
|
||||||
|
"admin" => false
|
||||||
},
|
},
|
||||||
"statusnet_profile_url" => user.ap_id,
|
"statusnet_profile_url" => user.ap_id,
|
||||||
"cover_photo" => banner,
|
"cover_photo" => banner,
|
||||||
|
|
Loading…
Reference in a new issue