Add missing docs and tests
This commit is contained in:
parent
1c265b3b19
commit
ed7fd6b47e
|
@ -1,108 +1,173 @@
|
||||||
# Admin API
|
# Admin API
|
||||||
|
|
||||||
Authentication is required and the user must be an admin.
|
Authentication is required and the user must be an admin.
|
||||||
|
|
||||||
|
## `/api/pleroma/admin/users`
|
||||||
|
|
||||||
|
### List users
|
||||||
|
|
||||||
|
- Method `GET`
|
||||||
|
- Response:
|
||||||
|
|
||||||
|
```JSON
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"deactivated": bool,
|
||||||
|
"id": integer,
|
||||||
|
"nickname": string
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
## `/api/pleroma/admin/user`
|
## `/api/pleroma/admin/user`
|
||||||
|
|
||||||
### Remove a user
|
### Remove a user
|
||||||
* Method `DELETE`
|
|
||||||
* Params:
|
- Method `DELETE`
|
||||||
* `nickname`
|
- Params:
|
||||||
* Response: User’s nickname
|
- `nickname`
|
||||||
|
- Response: User’s nickname
|
||||||
|
|
||||||
### Create a user
|
### Create a user
|
||||||
* Method: `POST`
|
|
||||||
* Params:
|
|
||||||
* `nickname`
|
|
||||||
* `email`
|
|
||||||
* `password`
|
|
||||||
* Response: User’s nickname
|
|
||||||
|
|
||||||
## `/api/pleroma/admin/users/tag`
|
- Method: `POST`
|
||||||
### Tag a list of users
|
- Params:
|
||||||
* Method: `PUT`
|
- `nickname`
|
||||||
* Params:
|
- `email`
|
||||||
* `nickname`
|
- `password`
|
||||||
* `tags`
|
- Response: User’s nickname
|
||||||
### Untag a list of users
|
|
||||||
* Method: `DELETE`
|
## `/api/pleroma/admin/users/:nickname/toggle_activation`
|
||||||
* Params:
|
|
||||||
* `nickname`
|
### Toggle user activation
|
||||||
* `tags`
|
|
||||||
|
- Method: `PATCH`
|
||||||
|
- Params:
|
||||||
|
- `nickname`
|
||||||
|
- Response: User’s object
|
||||||
|
|
||||||
## `/api/pleroma/admin/permission_group/:nickname`
|
|
||||||
### Get user user permission groups membership
|
|
||||||
* Method: `GET`
|
|
||||||
* Params: none
|
|
||||||
* Response:
|
|
||||||
```JSON
|
```JSON
|
||||||
{
|
{
|
||||||
"is_moderator": bool,
|
"deactivated": bool,
|
||||||
"is_admin": bool
|
"id": integer,
|
||||||
|
"nickname": string
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## `/api/pleroma/admin/users/tag`
|
||||||
|
|
||||||
|
### Tag a list of users
|
||||||
|
|
||||||
|
- Method: `PUT`
|
||||||
|
- Params:
|
||||||
|
- `nickname`
|
||||||
|
- `tags`
|
||||||
|
|
||||||
|
### Untag a list of users
|
||||||
|
|
||||||
|
- Method: `DELETE`
|
||||||
|
- Params:
|
||||||
|
- `nickname`
|
||||||
|
- `tags`
|
||||||
|
|
||||||
|
## `/api/pleroma/admin/permission_group/:nickname`
|
||||||
|
|
||||||
|
### Get user user permission groups membership
|
||||||
|
|
||||||
|
- Method: `GET`
|
||||||
|
- Params: none
|
||||||
|
- Response:
|
||||||
|
|
||||||
|
```JSON
|
||||||
|
{
|
||||||
|
"is_moderator": bool,
|
||||||
|
"is_admin": bool
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## `/api/pleroma/admin/permission_group/:nickname/:permission_group`
|
## `/api/pleroma/admin/permission_group/:nickname/:permission_group`
|
||||||
|
|
||||||
Note: Available `:permission_group` is currently moderator and admin. 404 is returned when the permission group doesn’t exist.
|
Note: Available `:permission_group` is currently moderator and admin. 404 is returned when the permission group doesn’t exist.
|
||||||
|
|
||||||
### Get user user permission groups membership
|
### Get user user permission groups membership
|
||||||
* Method: `GET`
|
|
||||||
* Params: none
|
- Method: `GET`
|
||||||
* Response:
|
- Params: none
|
||||||
|
- Response:
|
||||||
|
|
||||||
```JSON
|
```JSON
|
||||||
{
|
{
|
||||||
"is_moderator": bool,
|
"is_moderator": bool,
|
||||||
"is_admin": bool
|
"is_admin": bool
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Add user in permission group
|
### Add user in permission group
|
||||||
* Method: `POST`
|
|
||||||
* Params: none
|
- Method: `POST`
|
||||||
* Response:
|
- Params: none
|
||||||
* On failure: ``{"error": "…"}``
|
- Response:
|
||||||
* On success: JSON of the ``user.info``
|
- On failure: `{"error": "…"}`
|
||||||
|
- On success: JSON of the `user.info`
|
||||||
|
|
||||||
### Remove user from permission group
|
### Remove user from permission group
|
||||||
* Method: `DELETE`
|
|
||||||
* Params: none
|
- Method: `DELETE`
|
||||||
* Response:
|
- Params: none
|
||||||
* On failure: ``{"error": "…"}``
|
- Response:
|
||||||
* On success: JSON of the ``user.info``
|
- On failure: `{"error": "…"}`
|
||||||
* Note: An admin cannot revoke their own admin status.
|
- On success: JSON of the `user.info`
|
||||||
|
- Note: An admin cannot revoke their own admin status.
|
||||||
|
|
||||||
## `/api/pleroma/admin/activation_status/:nickname`
|
## `/api/pleroma/admin/activation_status/:nickname`
|
||||||
|
|
||||||
### Active or deactivate a user
|
### Active or deactivate a user
|
||||||
* Method: `PUT`
|
|
||||||
* Params:
|
- Method: `PUT`
|
||||||
* `nickname`
|
- Params:
|
||||||
* `status` BOOLEAN field, false value means deactivation.
|
- `nickname`
|
||||||
|
- `status` BOOLEAN field, false value means deactivation.
|
||||||
|
|
||||||
## `/api/pleroma/admin/relay`
|
## `/api/pleroma/admin/relay`
|
||||||
|
|
||||||
### Follow a Relay
|
### Follow a Relay
|
||||||
* Methods: `POST`
|
|
||||||
* Params:
|
- Methods: `POST`
|
||||||
* `relay_url`
|
- Params:
|
||||||
* Response:
|
- `relay_url`
|
||||||
* On success: URL of the followed relay
|
- Response:
|
||||||
|
- On success: URL of the followed relay
|
||||||
|
|
||||||
### Unfollow a Relay
|
### Unfollow a Relay
|
||||||
* Methods: `DELETE`
|
|
||||||
* Params:
|
- Methods: `DELETE`
|
||||||
* `relay_url`
|
- Params:
|
||||||
* Response:
|
- `relay_url`
|
||||||
* On success: URL of the unfollowed relay
|
- Response:
|
||||||
|
- On success: URL of the unfollowed relay
|
||||||
|
|
||||||
## `/api/pleroma/admin/invite_token`
|
## `/api/pleroma/admin/invite_token`
|
||||||
|
|
||||||
### Get a account registeration invite token
|
### Get a account registeration invite token
|
||||||
* Methods: `GET`
|
|
||||||
* Params: none
|
- Methods: `GET`
|
||||||
* Response: invite token (base64 string)
|
- Params: none
|
||||||
|
- Response: invite token (base64 string)
|
||||||
|
|
||||||
## `/api/pleroma/admin/email_invite`
|
## `/api/pleroma/admin/email_invite`
|
||||||
|
|
||||||
### Sends registration invite via email
|
### Sends registration invite via email
|
||||||
* Methods: `POST`
|
|
||||||
* Params:
|
- Methods: `POST`
|
||||||
* `email`
|
- Params:
|
||||||
* `name`, optionnal
|
- `email`
|
||||||
|
- `name`, optionnal
|
||||||
|
|
||||||
## `/api/pleroma/admin/password_reset`
|
## `/api/pleroma/admin/password_reset`
|
||||||
|
|
||||||
### Get a password reset token for a given nickname
|
### Get a password reset token for a given nickname
|
||||||
* Methods: `GET`
|
|
||||||
* Params: none
|
- Methods: `GET`
|
||||||
* Response: password reset token (base64 string)
|
- Params: none
|
||||||
|
- Response: password reset token (base64 string)
|
||||||
|
|
|
@ -330,4 +330,39 @@ test "/api/pleroma/admin/password_reset" do
|
||||||
|
|
||||||
assert conn.status == 200
|
assert conn.status == 200
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "GET /api/pleroma/admin/users" do
|
||||||
|
admin = insert(:user, info: %{is_admin: true})
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
conn =
|
||||||
|
build_conn()
|
||||||
|
|> assign(:user, admin)
|
||||||
|
|> get("/api/pleroma/admin/users")
|
||||||
|
|
||||||
|
assert json_response(conn, 200) == [
|
||||||
|
%{
|
||||||
|
"deactivated" => user.info.deactivated,
|
||||||
|
"id" => user.id,
|
||||||
|
"nickname" => user.nickname
|
||||||
|
}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
test "PATCH /api/pleroma/admin/users/:nickname/toggle_activation" do
|
||||||
|
admin = insert(:user, info: %{is_admin: true})
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
conn =
|
||||||
|
build_conn()
|
||||||
|
|> assign(:user, admin)
|
||||||
|
|> patch("/api/pleroma/admin/users/#{user.nickname}/toggle_activation")
|
||||||
|
|
||||||
|
assert json_response(conn, 200) ==
|
||||||
|
%{
|
||||||
|
"deactivated" => !user.info.deactivated,
|
||||||
|
"id" => user.id,
|
||||||
|
"nickname" => user.nickname
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue