Add get endpoints for rights [AdminAPI]
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 2 Nov 2018 07:19:56 +0000 (08:19 +0100)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sat, 17 Nov 2018 19:25:55 +0000 (20:25 +0100)
lib/pleroma/web/admin_api/admin_api_controller.ex
lib/pleroma/web/router.ex

index a7be3611fceff626584bb4571fae607d9d7427b3..17f5f320d8d23ecac111086087c979fc3a051d36 100644 (file)
@@ -56,6 +56,13 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
     |> json(user.info)
   end
 
+  def right_get(conn, %{"nickname" => nickname}) do
+    user = User.get_by_nickname(nickname)
+
+    conn
+    |> json(user.info)
+  end
+
   def right_add(conn, _) do
     conn
     |> put_status(404)
index 4d942297045a50526991f64c903479b98e526ef5..281e816c13d0dfbac6cf988db20881fd8d735237 100644 (file)
@@ -99,8 +99,10 @@ defmodule Pleroma.Web.Router do
     delete("/user", AdminAPIController, :user_delete)
     post("/user", AdminAPIController, :user_create)
 
-    post("/rights/:right/:nickname", AdminAPIController, :right_add)
-    delete("/rights/:right/:nickname", AdminAPIController, :right_delete)
+    get("/rights/:nickname", AdminAPIController, :right_get)
+    get("/rights/:nickname/:right", AdminAPIController, :right_get)
+    post("/rights/:nickname/:right", AdminAPIController, :right_add)
+    delete("/rights/:nickname/:right", AdminAPIController, :right_delete)
 
     post("/relay", AdminAPIController, :relay_follow)
     delete("/relay", AdminAPIController, :relay_unfollow)