From 6284e8f4b2e9b737d1ed256e89f2ac3ba673d6f8 Mon Sep 17 00:00:00 2001 From: Ilja Date: Sun, 10 Jan 2021 08:25:36 +0000 Subject: Add development section * I cretaed a folder 'development' * I split up the file dev.md into three parts and moved it to this folder * index.md * authentication_authorization.md * mrf.md * I also moved ap_extensions.md * I created a new file setting_up_pleroma_dev.md --- .gitignore | 2 +- docs/API/admin_api.md | 1565 -------------------- docs/API/chats.md | 255 ---- docs/API/differences_in_mastoapi_responses.md | 346 ----- docs/API/pleroma_api.md | 655 -------- docs/API/prometheus.md | 44 - docs/ap_extensions.md | 65 - docs/configuration/mrf.md | 23 + docs/dev.md | 46 - docs/development/API/admin_api.md | 1565 ++++++++++++++++++++ docs/development/API/chats.md | 255 ++++ .../API/differences_in_mastoapi_responses.md | 346 +++++ docs/development/API/pleroma_api.md | 655 ++++++++ docs/development/API/prometheus.md | 44 + docs/development/ap_extensions.md | 65 + docs/development/authentication_authorization.md | 21 + docs/development/index.md | 1 + docs/development/setting_up_pleroma_dev.md | 70 + docs/installation/alpine_linux_en.md | 2 +- docs/installation/arch_linux_en.md | 2 +- docs/installation/debian_based_en.md | 2 +- docs/installation/debian_based_jp.md | 2 +- docs/installation/freebsd_en.md | 2 +- docs/installation/netbsd_en.md | 2 +- docs/installation/openbsd_en.md | 2 +- docs/installation/openbsd_fi.md | 2 +- ...20190510135645_add_fts_index_to_objects_two.exs | 29 +- 27 files changed, 3077 insertions(+), 2991 deletions(-) delete mode 100644 docs/API/admin_api.md delete mode 100644 docs/API/chats.md delete mode 100644 docs/API/differences_in_mastoapi_responses.md delete mode 100644 docs/API/pleroma_api.md delete mode 100644 docs/API/prometheus.md delete mode 100644 docs/ap_extensions.md delete mode 100644 docs/dev.md create mode 100644 docs/development/API/admin_api.md create mode 100644 docs/development/API/chats.md create mode 100644 docs/development/API/differences_in_mastoapi_responses.md create mode 100644 docs/development/API/pleroma_api.md create mode 100644 docs/development/API/prometheus.md create mode 100644 docs/development/ap_extensions.md create mode 100644 docs/development/authentication_authorization.md create mode 100644 docs/development/index.md create mode 100644 docs/development/setting_up_pleroma_dev.md diff --git a/.gitignore b/.gitignore index 62ca61bce..4dea75e93 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,7 @@ erl_crash.dump # Database setup file, some may forget to delete it -/config/setup_db.psql +/config/setup_db*.psql .DS_Store .env diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md deleted file mode 100644 index 5253dc668..000000000 --- a/docs/API/admin_api.md +++ /dev/null @@ -1,1565 +0,0 @@ -# Admin API - -Authentication is required and the user must be an admin. - -Configuration options: - -* `[:auth, :enforce_oauth_admin_scope_usage]` — OAuth admin scope requirement toggle. - If `true`, admin actions explicitly demand admin OAuth scope(s) presence in OAuth token (client app must support admin scopes). - If `false` and token doesn't have admin scope(s), `is_admin` user flag grants access to admin-specific actions. - Note that client app needs to explicitly support admin scopes and request them when obtaining auth token. - -## `GET /api/pleroma/admin/users` - -### List users - -- Query Params: - - *optional* `query`: **string** search term (e.g. nickname, domain, nickname@domain) - - *optional* `filters`: **string** comma-separated string of filters: - - `local`: only local users - - `external`: only external users - - `active`: only active users - - `need_approval`: only unapproved users - - `unconfirmed`: only unconfirmed users - - `deactivated`: only deactivated users - - `is_admin`: users with admin role - - `is_moderator`: users with moderator role - - *optional* `page`: **integer** page number - - *optional* `page_size`: **integer** number of users per page (default is `50`) - - *optional* `tags`: **[string]** tags list - - *optional* `actor_types`: **[string]** actor type list (`Person`, `Service`, `Application`) - - *optional* `name`: **string** user display name - - *optional* `email`: **string** user email -- Example: `https://mypleroma.org/api/pleroma/admin/users?query=john&filters=local,active&page=1&page_size=10&tags[]=some_tag&tags[]=another_tag&name=display_name&email=email@example.com` -- Response: - -```json -{ - "page_size": integer, - "count": integer, - "users": [ - { - "deactivated": bool, - "id": integer, - "nickname": string, - "roles": { - "admin": bool, - "moderator": bool - }, - "local": bool, - "tags": array, - "avatar": string, - "display_name": string, - "confirmation_pending": bool, - "approval_pending": bool, - "registration_reason": string, - }, - ... - ] -} -``` - -## DEPRECATED `DELETE /api/pleroma/admin/users` - -### Remove a user - -- Params: - - `nickname` -- Response: User’s nickname - -## `DELETE /api/pleroma/admin/users` - -### Remove a user - -- Params: - - `nicknames` -- Response: Array of user nicknames - -### Create a user - -- Method: `POST` -- Params: - `users`: [ - { - `nickname`, - `email`, - `password` - } - ] -- Response: User’s nickname - -## `POST /api/pleroma/admin/users/follow` - -### Make a user follow another user - -- Params: - - `follower`: The nickname of the follower - - `followed`: The nickname of the followed -- Response: - - "ok" - -## `POST /api/pleroma/admin/users/unfollow` - -### Make a user unfollow another user - -- Params: - - `follower`: The nickname of the follower - - `followed`: The nickname of the followed -- Response: - - "ok" - -## `PATCH /api/pleroma/admin/users/:nickname/toggle_activation` - -### Toggle user activation - -- Params: - - `nickname` -- Response: User’s object - -```json -{ - "deactivated": bool, - "id": integer, - "nickname": string -} -``` - -## `PUT /api/pleroma/admin/users/tag` - -### Tag a list of users - -- Params: - - `nicknames` (array) - - `tags` (array) - -## `DELETE /api/pleroma/admin/users/tag` - -### Untag a list of users - -- Params: - - `nicknames` (array) - - `tags` (array) - -## `GET /api/pleroma/admin/users/:nickname/permission_group` - -### Get user user permission groups membership - -- Params: none -- Response: - -```json -{ - "is_moderator": bool, - "is_admin": bool -} -``` - -## `GET /api/pleroma/admin/users/:nickname/permission_group/:permission_group` - -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 per permission group - -- Params: none -- Response: - -```json -{ - "is_moderator": bool, - "is_admin": bool -} -``` - -## DEPRECATED `POST /api/pleroma/admin/users/:nickname/permission_group/:permission_group` - -### Add user to permission group - -- Params: none -- Response: - - On failure: `{"error": "…"}` - - On success: JSON of the user - -## `POST /api/pleroma/admin/users/permission_group/:permission_group` - -### Add users to permission group - -- Params: - - `nicknames`: nicknames array -- Response: - - On failure: `{"error": "…"}` - - On success: JSON of the user - -## DEPRECATED `DELETE /api/pleroma/admin/users/:nickname/permission_group/:permission_group` - -## `DELETE /api/pleroma/admin/users/:nickname/permission_group/:permission_group` - -### Remove user from permission group - -- Params: none -- Response: - - On failure: `{"error": "…"}` - - On success: JSON of the user -- Note: An admin cannot revoke their own admin status. - -## `DELETE /api/pleroma/admin/users/permission_group/:permission_group` - -### Remove users from permission group - -- Params: - - `nicknames`: nicknames array -- Response: - - On failure: `{"error": "…"}` - - On success: JSON of the user -- Note: An admin cannot revoke their own admin status. - -## `PATCH /api/pleroma/admin/users/activate` - -### Activate user - -- Params: - - `nicknames`: nicknames array -- Response: - -```json -{ - users: [ - { - // user object - } - ] -} -``` - -## `PATCH /api/pleroma/admin/users/deactivate` - -### Deactivate user - -- Params: - - `nicknames`: nicknames array -- Response: - -```json -{ - users: [ - { - // user object - } - ] -} -``` - -## `PATCH /api/pleroma/admin/users/approve` - -### Approve user - -- Params: - - `nicknames`: nicknames array -- Response: - -```json -{ - users: [ - { - // user object - } - ] -} -``` - -## `GET /api/pleroma/admin/users/:nickname_or_id` - -### Retrive the details of a user - -- Params: - - `nickname` or `id` -- Response: - - On failure: `Not found` - - On success: JSON of the user - -## `GET /api/pleroma/admin/users/:nickname_or_id/statuses` - -### Retrive user's latest statuses - -- Params: - - `nickname` or `id` - - *optional* `page_size`: number of statuses to return (default is `20`) - - *optional* `godmode`: `true`/`false` – allows to see private statuses - - *optional* `with_reblogs`: `true`/`false` – allows to see reblogs (default is false) -- Response: - - On failure: `Not found` - - On success: JSON array of user's latest statuses - -## `GET /api/pleroma/admin/instances/:instance/statuses` - -### Retrive instance's latest statuses - -- Params: - - `instance`: instance name - - *optional* `page_size`: number of statuses to return (default is `20`) - - *optional* `godmode`: `true`/`false` – allows to see private statuses - - *optional* `with_reblogs`: `true`/`false` – allows to see reblogs (default is false) -- Response: - - On failure: `Not found` - - On success: JSON array of instance's latest statuses - -## `GET /api/pleroma/admin/statuses` - -### Retrives all latest statuses - -- Params: - - *optional* `page_size`: number of statuses to return (default is `20`) - - *optional* `local_only`: excludes remote statuses - - *optional* `godmode`: `true`/`false` – allows to see private statuses - - *optional* `with_reblogs`: `true`/`false` – allows to see reblogs (default is false) -- Response: - - On failure: `Not found` - - On success: JSON array of user's latest statuses - -## `GET /api/pleroma/admin/relay` - -### List Relays - -Params: none -Response: - -* On success: JSON array of relays - -```json -[ - {"actor": "https://example.com/relay", "followed_back": true}, - {"actor": "https://example2.com/relay", "followed_back": false} -] -``` - -## `POST /api/pleroma/admin/relay` - -### Follow a Relay - -Params: - -* `relay_url` - -Response: - -* On success: relay json object - -```json -{"actor": "https://example.com/relay", "followed_back": true} -``` - -## `DELETE /api/pleroma/admin/relay` - -### Unfollow a Relay - -- Params: - - `relay_url` - - *optional* `force`: forcefully unfollow a relay even when the relay is not available. (default is `false`) - -Response: - -* On success: URL of the unfollowed relay - -```json -{"https://example.com/relay"} -``` - -## `POST /api/pleroma/admin/users/invite_token` - -### Create an account registration invite token - -- Params: - - *optional* `max_use` (integer) - - *optional* `expires_at` (date string e.g. "2019-04-07") -- Response: - -```json -{ - "id": integer, - "token": string, - "used": boolean, - "expires_at": date, - "uses": integer, - "max_use": integer, - "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`) -} -``` - -## `GET /api/pleroma/admin/users/invites` - -### Get a list of generated invites - -- Params: none -- Response: - -```json -{ - - "invites": [ - { - "id": integer, - "token": string, - "used": boolean, - "expires_at": date, - "uses": integer, - "max_use": integer, - "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`) - }, - ... - ] -} -``` - -## `POST /api/pleroma/admin/users/revoke_invite` - -### Revoke invite by token - -- Params: - - `token` -- Response: - -```json -{ - "id": integer, - "token": string, - "used": boolean, - "expires_at": date, - "uses": integer, - "max_use": integer, - "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`) - -} -``` - -## `POST /api/pleroma/admin/users/email_invite` - -### Sends registration invite via email - -- Params: - - `email` - - `name`, optional - -- Response: - - On success: `204`, empty response - - On failure: - - 400 Bad Request, JSON: - - ```json - [ - { - "error": "Appropriate error message here" - } - ] - ``` - -## `GET /api/pleroma/admin/users/:nickname/password_reset` - -### Get a password reset token for a given nickname - - -- Params: none -- Response: - -```json -{ - "token": "base64 reset token", - "link": "https://pleroma.social/api/pleroma/password_reset/url-encoded-base64-token" -} -``` - -## `PATCH /api/pleroma/admin/users/force_password_reset` - -### Force passord reset for a user with a given nickname - -- Params: - - `nicknames` -- Response: none (code `204`) - -## PUT `/api/pleroma/admin/users/disable_mfa` - -### Disable mfa for user's account. - -- Params: - - `nickname` -- Response: User’s nickname - -## `GET /api/pleroma/admin/users/:nickname/credentials` - -### Get the user's email, password, display and settings-related fields - -- Params: - - `nickname` - -- Response: - -```json -{ - "actor_type": "Person", - "allow_following_move": true, - "avatar": "https://pleroma.social/media/7e8e7508fd545ef580549b6881d80ec0ff2c81ed9ad37b9bdbbdf0e0d030159d.jpg", - "background": "https://pleroma.social/media/4de34c0bd10970d02cbdef8972bef0ebbf55f43cadc449554d4396156162fe9a.jpg", - "banner": "https://pleroma.social/media/8d92ba2bd244b613520abf557dd448adcd30f5587022813ee9dd068945986946.jpg", - "bio": "bio", - "default_scope": "public", - "discoverable": false, - "email": "user@example.com", - "fields": [ - { - "name": "example", - "value": "https://example.com" - } - ], - "hide_favorites": false, - "hide_followers": false, - "hide_followers_count": false, - "hide_follows": false, - "hide_follows_count": false, - "id": "9oouHaEEUR54hls968", - "locked": true, - "name": "user", - "no_rich_text": true, - "pleroma_settings_store": {}, - "raw_fields": [ - { - "id": 1, - "name": "example", - "value": "https://example.com" - }, - ], - "show_role": true, - "skip_thread_containment": false -} -``` - -## `PATCH /api/pleroma/admin/users/:nickname/credentials` - -### Change the user's email, password, display and settings-related fields - -* Params: - * `email` - * `password` - * `name` - * `bio` - * `avatar` - * `locked` - * `no_rich_text` - * `default_scope` - * `banner` - * `hide_follows` - * `hide_followers` - * `hide_followers_count` - * `hide_follows_count` - * `hide_favorites` - * `allow_following_move` - * `background` - * `show_role` - * `skip_thread_containment` - * `fields` - * `is_discoverable` - * `actor_type` - -* Responses: - -Status: 200 - -```json -{"status": "success"} -``` - -Status: 400 - -```json -{"errors": - {"actor_type": "is invalid"}, - {"email": "has invalid format"}, - ... - } -``` - -Status: 404 - -```json -{"error": "Not found"} -``` - -## `GET /api/pleroma/admin/reports` - -### Get a list of reports - -- Params: - - *optional* `state`: **string** the state of reports. Valid values are `open`, `closed` and `resolved` - - *optional* `limit`: **integer** the number of records to retrieve - - *optional* `page`: **integer** page number - - *optional* `page_size`: **integer** number of log entries per page (default is `50`) -- Response: - - On failure: 403 Forbidden error `{"error": "error_msg"}` when requested by anonymous or non-admin - - On success: JSON, returns a list of reports, where: - - `account`: the user who has been reported - - `actor`: the user who has sent the report - - `statuses`: list of statuses that have been included to the report - -```json -{ - "total" : 1, - "reports": [ - { - "account": { - "acct": "user", - "avatar": "https://pleroma.example.org/images/avi.png", - "avatar_static": "https://pleroma.example.org/images/avi.png", - "bot": false, - "created_at": "2019-04-23T17:32:04.000Z", - "display_name": "User", - "emojis": [], - "fields": [], - "followers_count": 1, - "following_count": 1, - "header": "https://pleroma.example.org/images/banner.png", - "header_static": "https://pleroma.example.org/images/banner.png", - "id": "9i6dAJqSGSKMzLG2Lo", - "locked": false, - "note": "", - "pleroma": { - "confirmation_pending": false, - "hide_favorites": true, - "hide_followers": false, - "hide_follows": false, - "is_admin": false, - "is_moderator": false, - "relationship": {}, - "tags": [] - }, - "source": { - "note": "", - "pleroma": {}, - "sensitive": false - }, - "tags": ["force_unlisted"], - "statuses_count": 3, - "url": "https://pleroma.example.org/users/user", - "username": "user" - }, - "actor": { - "acct": "lain", - "avatar": "https://pleroma.example.org/images/avi.png", - "avatar_static": "https://pleroma.example.org/images/avi.png", - "bot": false, - "created_at": "2019-03-28T17:36:03.000Z", - "display_name": "Roger Braun", - "emojis": [], - "fields": [], - "followers_count": 1, - "following_count": 1, - "header": "https://pleroma.example.org/images/banner.png", - "header_static": "https://pleroma.example.org/images/banner.png", - "id": "9hEkA5JsvAdlSrocam", - "locked": false, - "note": "", - "pleroma": { - "confirmation_pending": false, - "hide_favorites": false, - "hide_followers": false, - "hide_follows": false, - "is_admin": false, - "is_moderator": false, - "relationship": {}, - "tags": [] - }, - "source": { - "note": "", - "pleroma": {}, - "sensitive": false - }, - "tags": ["force_unlisted"], - "statuses_count": 1, - "url": "https://pleroma.example.org/users/lain", - "username": "lain" - }, - "content": "Please delete it", - "created_at": "2019-04-29T19:48:15.000Z", - "id": "9iJGOv1j8hxuw19bcm", - "state": "open", - "statuses": [ - { - "account": { ... }, - "application": { - "name": "Web", - "website": null - }, - "bookmarked": false, - "card": null, - "content": "@lain click on my link https://www.google.com/", - "created_at": "2019-04-23T19:15:47.000Z", - "emojis": [], - "favourited": false, - "favourites_count": 0, - "id": "9i6mQ9uVrrOmOime8m", - "in_reply_to_account_id": null, - "in_reply_to_id": null, - "language": null, - "media_attachments": [], - "mentions": [ - { - "acct": "lain", - "id": "9hEkA5JsvAdlSrocam", - "url": "https://pleroma.example.org/users/lain", - "username": "lain" - }, - { - "acct": "user", - "id": "9i6dAJqSGSKMzLG2Lo", - "url": "https://pleroma.example.org/users/user", - "username": "user" - } - ], - "muted": false, - "pinned": false, - "pleroma": { - "content": { - "text/plain": "@lain click on my link https://www.google.com/" - }, - "conversation_id": 28, - "in_reply_to_account_acct": null, - "local": true, - "spoiler_text": { - "text/plain": "" - } - }, - "reblog": null, - "reblogged": false, - "reblogs_count": 0, - "replies_count": 0, - "sensitive": false, - "spoiler_text": "", - "tags": [], - "uri": "https://pleroma.example.org/objects/8717b90f-8e09-4b58-97b0-e3305472b396", - "url": "https://pleroma.example.org/notice/9i6mQ9uVrrOmOime8m", - "visibility": "direct" - } - ] - } - ] -} -``` - -## `GET /api/pleroma/admin/grouped_reports` - -### Get a list of reports, grouped by status - -- Params: none -- On success: JSON, returns a list of reports, where: - - `date`: date of the latest report - - `account`: the user who has been reported (see `/api/pleroma/admin/reports` for reference) - - `status`: reported status (see `/api/pleroma/admin/reports` for reference) - - `actors`: users who had reported this status (see `/api/pleroma/admin/reports` for reference) - - `reports`: reports (see `/api/pleroma/admin/reports` for reference) - -```json - "reports": [ - { - "date": "2019-10-07T12:31:39.615149Z", - "account": { ... }, - "status": { ... }, - "actors": [{ ... }, { ... }], - "reports": [{ ... }] - } - ] -``` - -## `GET /api/pleroma/admin/reports/:id` - -### Get an individual report - -- Params: - - `id` -- Response: - - On failure: - - 403 Forbidden `{"error": "error_msg"}` - - 404 Not Found `"Not found"` - - On success: JSON, Report object (see above) - -## `PATCH /api/pleroma/admin/reports` - -### Change the state of one or multiple reports - -- Params: - -```json - `reports`: [ - { - `id`, // required, report id - `state` // required, the new state. Valid values are `open`, `closed` and `resolved` - }, - ... - ] -``` - -- Response: - - On failure: - - 400 Bad Request, JSON: - - ```json - [ - { - `id`, // report id - `error` // error message - } - ] - ``` - - - On success: `204`, empty response - -## `POST /api/pleroma/admin/reports/:id/notes` - -### Create report note - -- Params: - - `id`: required, report id - - `content`: required, the message -- Response: - - On failure: - - 400 Bad Request `"Invalid parameters"` when `status` is missing - - On success: `204`, empty response - -## `DELETE /api/pleroma/admin/reports/:report_id/notes/:id` - -### Delete report note - -- Params: - - `report_id`: required, report id - - `id`: required, note id -- Response: - - On failure: - - 400 Bad Request `"Invalid parameters"` when `status` is missing - - On success: `204`, empty response - -## `GET /api/pleroma/admin/statuses/:id` - -### Show status by id - -- Params: - - `id`: required, status id -- Response: - - On failure: - - 404 Not Found `"Not Found"` - - On success: JSON, Mastodon Status entity - -## `PUT /api/pleroma/admin/statuses/:id` - -### Change the scope of an individual reported status - -- Params: - - `id` - - `sensitive`: optional, valid values are `true` or `false` - - `visibility`: optional, valid values are `public`, `private` and `unlisted` -- Response: - - On failure: - - 400 Bad Request `"Unsupported visibility"` - - 403 Forbidden `{"error": "error_msg"}` - - 404 Not Found `"Not found"` - - On success: JSON, Mastodon Status entity - -## `DELETE /api/pleroma/admin/statuses/:id` - -### Delete an individual reported status - -- Params: - - `id` -- Response: - - On failure: - - 403 Forbidden `{"error": "error_msg"}` - - 404 Not Found `"Not found"` - - On success: 200 OK `{}` - -## `GET /api/pleroma/admin/restart` - -### Restarts pleroma application - -**Only works when configuration from database is enabled.** - -- Params: none -- Response: - - On failure: - - 400 Bad Request `"To use this endpoint you need to enable configuration from database."` - -```json -{} -``` - -## `GET /api/pleroma/admin/need_reboot` - -### Returns the flag whether the pleroma should be restarted - -- Params: none -- Response: - - `need_reboot` - boolean -```json -{ - "need_reboot": false -} -``` - -## `GET /api/pleroma/admin/config` - -### Get list of merged default settings with saved in database. - -*If `need_reboot` is `true`, instance must be restarted, so reboot time settings can take effect.* - -**Only works when configuration from database is enabled.** - -- Params: - - `only_db`: true (*optional*, get only saved in database settings) -- Response: - - On failure: - - 400 Bad Request `"To use this endpoint you need to enable configuration from database."` - -```json -{ - "configs": [ - { - "group": ":pleroma", - "key": "Pleroma.Upload", - "value": [] - } - ], - "need_reboot": true -} -``` - -## `POST /api/pleroma/admin/config` - -### Update config settings - -*If `need_reboot` is `true`, instance must be restarted, so reboot time settings can take effect.* - -**Only works when configuration from database is enabled.** - -Some modifications are necessary to save the config settings correctly: - -- strings which start with `Pleroma.`, `Phoenix.`, `Tesla.` or strings like `Oban`, `Ueberauth` will be converted to modules; -``` -"Pleroma.Upload" -> Pleroma.Upload -"Oban" -> Oban -``` -- strings starting with `:` will be converted to atoms; -``` -":pleroma" -> :pleroma -``` -- objects with `tuple` key and array value will be converted to tuples; -``` -{"tuple": ["string", "Pleroma.Upload", []]} -> {"string", Pleroma.Upload, []} -``` -- arrays with *tuple objects* will be converted to keywords; -``` -[{"tuple": [":key1", "value"]}, {"tuple": [":key2", "value"]}] -> [key1: "value", key2: "value"] -``` - -Most of the settings will be applied in `runtime`, this means that you don't need to restart the instance. But some settings are applied in `compile time` and require a reboot of the instance, such as: -- all settings inside these keys: - - `:hackney_pools` - - `:connections_pool` - - `:pools` - - `:chat` -- partially settings inside these keys: - - `:seconds_valid` in `Pleroma.Captcha` - - `:proxy_remote` in `Pleroma.Upload` - - `:upload_limit` in `:instance` - -- Params: - - `configs` - array of config objects - - config object params: - - `group` - string (**required**) - - `key` - string (**required**) - - `value` - string, [], {} or {"tuple": []} (**required**) - - `delete` - true (*optional*, if setting must be deleted) - - `subkeys` - array of strings (*optional*, only works when `delete=true` parameter is passed, otherwise will be ignored) - -*When a value have several nested settings, you can delete only some nested settings by passing a parameter `subkeys`, without deleting all settings by key.* -``` -[subkey: val1, subkey2: val2, subkey3: val3] \\ initial value -{"group": ":pleroma", "key": "some_key", "delete": true, "subkeys": [":subkey", ":subkey3"]} \\ passing json for deletion -[subkey2: val2] \\ value after deletion -``` - -*Most of the settings can be partially updated through merge old values with new values, except settings value of which is list or is not keyword.* - -Example of setting without keyword in value: -```elixir -config :tesla, :adapter, Tesla.Adapter.Hackney -``` - -List of settings which support only full update by key: -```elixir -@full_key_update [ - {:pleroma, :ecto_repos}, - {:quack, :meta}, - {:mime, :types}, - {:cors_plug, [:max_age, :methods, :expose, :headers]}, - {:auto_linker, :opts}, - {:swarm, :node_blacklist}, - {:logger, :backends} - ] -``` - -List of settings which support only full update by subkey: -```elixir -@full_subkey_update [ - {:pleroma, :assets, :mascots}, - {:pleroma, :emoji, :groups}, - {:pleroma, :workers, :retries}, - {:pleroma, :mrf_subchain, :match_actor}, - {:pleroma, :mrf_keyword, :replace} - ] -``` - -*Settings without explicit key must be sended in separate config object params.* -```elixir -config :quack, - level: :debug, - meta: [:all], - ... -``` -```json -{ - "configs": [ - {"group": ":quack", "key": ":level", "value": ":debug"}, - {"group": ":quack", "key": ":meta", "value": [":all"]}, - ... - ] -} -``` -- Request: - -```json -{ - "configs": [ - { - "group": ":pleroma", - "key": "Pleroma.Upload", - "value": [ - {"tuple": [":uploader", "Pleroma.Uploaders.Local"]}, - {"tuple": [":filters", ["Pleroma.Upload.Filter.Dedupe"]]}, - {"tuple": [":link_name", true]}, - {"tuple": [":proxy_remote", false]}, - {"tuple": [":proxy_opts", [ - {"tuple": [":redirect_on_failure", false]}, - {"tuple": [":max_body_length", 1048576]}, - {"tuple": [":http", [ - {"tuple": [":follow_redirect", true]}, - {"tuple": [":pool", ":upload"]}, - ]]} - ] - ]}, - {"tuple": [":dispatch", { - "tuple": ["/api/v1/streaming", "Pleroma.Web.MastodonAPI.WebsocketHandler", []] - }]} - ] - } - ] -} -``` - -- Response: - - On failure: - - 400 Bad Request `"To use this endpoint you need to enable configuration from database."` -```json -{ - "configs": [ - { - "group": ":pleroma", - "key": "Pleroma.Upload", - "value": [...] - } - ], - "need_reboot": true -} -``` - -## ` GET /api/pleroma/admin/config/descriptions` - -### Get JSON with config descriptions. -Loads json generated from `config/descriptions.exs`. - -- Params: none -- Response: - -```json -[{ - "group": ":pleroma", // string - "key": "ModuleName", // string - "type": "group", // string or list with possible values, - "description": "Upload general settings", // string - "children": [ - { - "key": ":uploader", // string or module name `Pleroma.Upload` - "type": "module", - "description": "Module which will be used for uploads", - "suggestions": ["module1", "module2"] - }, - { - "key": ":filters", - "type": ["list", "module"], - "description": "List of filter modules for uploads", - "suggestions": [ - "module1", "module2", "module3" - ] - } - ] -}] -``` - -## `GET /api/pleroma/admin/moderation_log` - -### Get moderation log - -- Params: - - *optional* `page`: **integer** page number - - *optional* `page_size`: **integer** number of log entries per page (default is `50`) - - *optional* `start_date`: **datetime (ISO 8601)** filter logs by creation date, start from `start_date`. Accepts datetime in ISO 8601 format (YYYY-MM-DDThh:mm:ss), e.g. `2005-08-09T18:31:42` - - *optional* `end_date`: **datetime (ISO 8601)** filter logs by creation date, end by from `end_date`. Accepts datetime in ISO 8601 format (YYYY-MM-DDThh:mm:ss), e.g. 2005-08-09T18:31:42 - - *optional* `user_id`: **integer** filter logs by actor's id - - *optional* `search`: **string** search logs by the log message -- Response: - -```json -[ - { - "id": 1234, - "data": { - "actor": { - "id": 1, - "nickname": "lain" - }, - "action": "relay_follow" - }, - "time": 1502812026, // timestamp - "message": "[2017-08-15 15:47:06] @nick0 followed relay: https://example.org/relay" // log message - } -] -``` - -## `POST /api/pleroma/admin/reload_emoji` - -### Reload the instance's custom emoji - -- Authentication: required -- Params: None -- Response: JSON, "ok" and 200 status - -## `PATCH /api/pleroma/admin/users/confirm_email` - -### Confirm users' emails - -- Params: - - `nicknames` -- Response: Array of user nicknames - -## `PATCH /api/pleroma/admin/users/resend_confirmation_email` - -### Resend confirmation email - -- Params: - - `nicknames` -- Response: Array of user nicknames - -## `GET /api/pleroma/admin/stats` - -### Stats - -- Query Params: - - *optional* `instance`: **string** instance hostname (without protocol) to get stats for -- Example: `https://mypleroma.org/api/pleroma/admin/stats?instance=lain.com` - -- Response: - -```json -{ - "status_visibility": { - "direct": 739, - "private": 9, - "public": 17, - "unlisted": 14 - } -} -``` - -## `GET /api/pleroma/admin/oauth_app` - -### List OAuth app - -- Params: - - *optional* `name` - - *optional* `client_id` - - *optional* `page` - - *optional* `page_size` - - *optional* `trusted` - -- Response: - -```json -{ - "apps": [ - { - "id": 1, - "name": "App name", - "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk", - "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY", - "redirect_uri": "https://example.com/oauth-callback", - "website": "https://example.com", - "trusted": true - } - ], - "count": 17, - "page_size": 50 -} -``` - - -## `POST /api/pleroma/admin/oauth_app` - -### Create OAuth App - -- Params: - - `name` - - `redirect_uris` - - `scopes` - - *optional* `website` - - *optional* `trusted` - -- Response: - -```json -{ - "id": 1, - "name": "App name", - "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk", - "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY", - "redirect_uri": "https://example.com/oauth-callback", - "website": "https://example.com", - "trusted": true -} -``` - -- On failure: -```json -{ - "redirect_uris": "can't be blank", - "name": "can't be blank" -} -``` - -## `PATCH /api/pleroma/admin/oauth_app/:id` - -### Update OAuth App - -- Params: - - *optional* `name` - - *optional* `redirect_uris` - - *optional* `scopes` - - *optional* `website` - - *optional* `trusted` - -- Response: - -```json -{ - "id": 1, - "name": "App name", - "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk", - "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY", - "redirect_uri": "https://example.com/oauth-callback", - "website": "https://example.com", - "trusted": true -} -``` - -## `DELETE /api/pleroma/admin/oauth_app/:id` - -### Delete OAuth App - -- Params: None - -- Response: - - On success: `204`, empty response - - On failure: - - 400 Bad Request `"Invalid parameters"` when `status` is missing - -## `GET /api/pleroma/admin/media_proxy_caches` - -### Get a list of all banned MediaProxy URLs in Cachex - -- Authentication: required -- Params: -- *optional* `page`: **integer** page number -- *optional* `page_size`: **integer** number of log entries per page (default is `50`) -- *optional* `query`: **string** search term - -- Response: - -``` json -{ - "page_size": integer, - "count": integer, - "urls": [ - "http://example.com/media/a688346.jpg", - "http://example.com/media/fb1f4d.jpg" - ] -} - -``` - -## `POST /api/pleroma/admin/media_proxy_caches/delete` - -### Remove a banned MediaProxy URL from Cachex - -- Authentication: required -- Params: - - `urls` (array) - -- Response: - -``` json -{ } - -``` - -## `POST /api/pleroma/admin/media_proxy_caches/purge` - -### Purge a MediaProxy URL - -- Authentication: required -- Params: - - `urls` (array) - - `ban` (boolean) - -- Response: - -``` json -{ } - -``` - -## GET /api/pleroma/admin/users/:nickname/chats - -### List a user's chats - -- Params: None - -- Response: - -```json -[ - { - "sender": { - "id": "someflakeid", - "username": "somenick", - ... - }, - "receiver": { - "id": "someflakeid", - "username": "somenick", - ... - }, - "id" : "1", - "unread" : 2, - "last_message" : {...}, // The last message in that chat - "updated_at": "2020-04-21T15:11:46.000Z" - } -] -``` - -## GET /api/pleroma/admin/chats/:chat_id - -### View a single chat - -- Params: None - -- Response: - -```json -{ - "sender": { - "id": "someflakeid", - "username": "somenick", - ... - }, - "receiver": { - "id": "someflakeid", - "username": "somenick", - ... - }, - "id" : "1", - "unread" : 2, - "last_message" : {...}, // The last message in that chat - "updated_at": "2020-04-21T15:11:46.000Z" -} -``` - -## GET /api/pleroma/admin/chats/:chat_id/messages - -### List the messages in a chat - -- Params: `max_id`, `min_id` - -- Response: - -```json -[ - { - "account_id": "someflakeid", - "chat_id": "1", - "content": "Check this out :firefox:", - "created_at": "2020-04-21T15:11:46.000Z", - "emojis": [ - { - "shortcode": "firefox", - "static_url": "https://dontbulling.me/emoji/Firefox.gif", - "url": "https://dontbulling.me/emoji/Firefox.gif", - "visible_in_picker": false - } - ], - "id": "13", - "unread": true - }, - { - "account_id": "someflakeid", - "chat_id": "1", - "content": "Whats' up?", - "created_at": "2020-04-21T15:06:45.000Z", - "emojis": [], - "id": "12", - "unread": false - } -] -``` - -## DELETE /api/pleroma/admin/chats/:chat_id/messages/:message_id - -### Delete a single message - -- Params: None - -- Response: - -```json -{ - "account_id": "someflakeid", - "chat_id": "1", - "content": "Check this out :firefox:", - "created_at": "2020-04-21T15:11:46.000Z", - "emojis": [ - { - "shortcode": "firefox", - "static_url": "https://dontbulling.me/emoji/Firefox.gif", - "url": "https://dontbulling.me/emoji/Firefox.gif", - "visible_in_picker": false - } - ], - "id": "13", - "unread": false -} -``` - -## `GET /api/pleroma/admin/instance_document/:document_name` - -### Get an instance document - -- Authentication: required - -- Response: - -Returns the content of the document - -```html -

Instance panel

-``` - -## `PATCH /api/pleroma/admin/instance_document/:document_name` -- Params: - - `file` (the file to be uploaded, using multipart form data.) - -### Update an instance document - -- Authentication: required - -- Response: - -``` json -{ - "url": "https://example.com/instance/panel.html" -} -``` - -## `DELETE /api/pleroma/admin/instance_document/:document_name` - -### Delete an instance document - -- Response: - -``` json -{ - "url": "https://example.com/instance/panel.html" -} -``` - -## `GET /api/pleroma/admin/frontends - -### List available frontends - -- Response: - -```json -[ - { - "build_url": "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build", - "git": "https://git.pleroma.social/pleroma/fedi-fe", - "installed": true, - "name": "fedi-fe", - "ref": "master" - }, - { - "build_url": "https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build", - "git": "https://git.pleroma.social/lambadalambda/kenoma", - "installed": false, - "name": "kenoma", - "ref": "master" - } -] -``` - -## `POST /api/pleroma/admin/frontends/install` - -### Install a frontend - -- Params: - - `name`: frontend name, required - - `ref`: frontend ref - - `file`: path to a frontend zip file - - `build_url`: build URL - - `build_dir`: build directory - -- Response: - -```json -[ - { - "build_url": "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build", - "git": "https://git.pleroma.social/pleroma/fedi-fe", - "installed": true, - "name": "fedi-fe", - "ref": "master" - }, - { - "build_url": "https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build", - "git": "https://git.pleroma.social/lambadalambda/kenoma", - "installed": false, - "name": "kenoma", - "ref": "master" - } -] -``` - -```json -{ - "error": "Could not install frontend" -} -``` diff --git a/docs/API/chats.md b/docs/API/chats.md deleted file mode 100644 index f50144c86..000000000 --- a/docs/API/chats.md +++ /dev/null @@ -1,255 +0,0 @@ -# Chats - -Chats are a way to represent an IM-style conversation between two actors. They are not the same as direct messages and they are not `Status`es, even though they have a lot in common. - -## Why Chats? - -There are no 'visibility levels' in ActivityPub, their definition is purely a Mastodon convention. Direct Messaging between users on the fediverse has mostly been modeled by using ActivityPub addressing following Mastodon conventions on normal `Note` objects. In this case, a 'direct message' would be a message that has no followers addressed and also does not address the special public actor, but just the recipients in the `to` field. It would still be a `Note` and is presented with other `Note`s as a `Status` in the API. - -This is an awkward setup for a few reasons: - -- As DMs generally still follow the usual `Status` conventions, it is easy to accidentally pull somebody into a DM thread by mentioning them. (e.g. "I hate @badguy so much") -- It is possible to go from a publicly addressed `Status` to a DM reply, back to public, then to a 'followers only' reply, and so on. This can be become very confusing, as it is unclear which user can see which part of the conversation. -- The standard `Status` format of implicit addressing also leads to rather ugly results if you try to display the messages as a chat, because all the recipients are always mentioned by name in the message. -- As direct messages are posted with the same api call (and usually same frontend component) as public messages, accidentally making a public message private or vice versa can happen easily. Client bugs can also lead to this, accidentally making private messages public. - -As a measure to improve this situation, the `Conversation` concept and related Pleroma extensions were introduced. While it made it possible to work around a few of the issues, many of the problems remained and it didn't see much adoption because it was too complicated to use correctly. - -## Chats explained -For this reasons, Chats are a new and different entity, both in the API as well as in ActivityPub. A quick overview: - -- Chats are meant to represent an instant message conversation between two actors. For now these are only 1-on-1 conversations, but the other actor can be a group in the future. -- Chat messages have the ActivityPub type `ChatMessage`. They are not `Note`s. Servers that don't understand them will just drop them. -- The only addressing allowed in `ChatMessage`s is one single ActivityPub actor in the `to` field. -- There's always only one Chat between two actors. If you start chatting with someone and later start a 'new' Chat, the old Chat will be continued. -- `ChatMessage`s are posted with a different api, making it very hard to accidentally send a message to the wrong person. -- `ChatMessage`s don't show up in the existing timelines. -- Chats can never go from private to public. They are always private between the two actors. - -## Caveats - -- Chats are NOT E2E encrypted (yet). Security is still the same as email. - -## API - -In general, the way to send a `ChatMessage` is to first create a `Chat`, then post a message to that `Chat`. `Group`s will later be supported by making them a sub-type of `Account`. - -This is the overview of using the API. The API is also documented via OpenAPI, so you can view it and play with it by pointing SwaggerUI or a similar OpenAPI tool to `https://yourinstance.tld/api/openapi`. - -### Creating or getting a chat. - -To create or get an existing Chat for a certain recipient (identified by Account ID) -you can call: - -`POST /api/v1/pleroma/chats/by-account-id/:account_id` - -The account id is the normal FlakeId of the user -``` -POST /api/v1/pleroma/chats/by-account-id/someflakeid -``` - -If you already have the id of a chat, you can also use - -``` -GET /api/v1/pleroma/chats/:id -``` - -There will only ever be ONE Chat for you and a given recipient, so this call -will return the same Chat if you already have one with that user. - -Returned data: - -```json -{ - "account": { - "id": "someflakeid", - "username": "somenick", - ... - }, - "id" : "1", - "unread" : 2, - "last_message" : {...}, // The last message in that chat - "updated_at": "2020-04-21T15:11:46.000Z" -} -``` - -### Marking a chat as read - -To mark a number of messages in a chat up to a certain message as read, you can use - -`POST /api/v1/pleroma/chats/:id/read` - - -Parameters: -- last_read_id: Given this id, all chat messages until this one will be marked as read. Required. - - -Returned data: - -```json -{ - "account": { - "id": "someflakeid", - "username": "somenick", - ... - }, - "id" : "1", - "unread" : 0, - "updated_at": "2020-04-21T15:11:46.000Z" -} -``` - -### Marking a single chat message as read - -To set the `unread` property of a message to `false` - -`POST /api/v1/pleroma/chats/:id/messages/:message_id/read` - -Returned data: - -The modified chat message - -### Getting a list of Chats - -`GET /api/v1/pleroma/chats` - -This will return a list of chats that you have been involved in, sorted by their -last update (so new chats will be at the top). - -Parameters: - -- with_muted: Include chats from muted users (boolean). - -Returned data: - -```json -[ - { - "account": { - "id": "someflakeid", - "username": "somenick", - ... - }, - "id" : "1", - "unread" : 2, - "last_message" : {...}, // The last message in that chat - "updated_at": "2020-04-21T15:11:46.000Z" - } -] -``` - -The recipient of messages that are sent to this chat is given by their AP ID. -No pagination is implemented for now. - -### Getting the messages for a Chat - -For a given Chat id, you can get the associated messages with - -`GET /api/v1/pleroma/chats/:id/messages` - -This will return all messages, sorted by most recent to least recent. The usual -pagination options are implemented. - -Returned data: - -```json -[ - { - "account_id": "someflakeid", - "chat_id": "1", - "content": "Check this out :firefox:", - "created_at": "2020-04-21T15:11:46.000Z", - "emojis": [ - { - "shortcode": "firefox", - "static_url": "https://dontbulling.me/emoji/Firefox.gif", - "url": "https://dontbulling.me/emoji/Firefox.gif", - "visible_in_picker": false - } - ], - "id": "13", - "unread": true - }, - { - "account_id": "someflakeid", - "chat_id": "1", - "content": "Whats' up?", - "created_at": "2020-04-21T15:06:45.000Z", - "emojis": [], - "id": "12", - "unread": false, - "idempotency_key": "75442486-0874-440c-9db1-a7006c25a31f" - } -] -``` - -- idempotency_key: The copy of the `idempotency-key` HTTP request header that can be used for optimistic message sending. Included only during the first few minutes after the message creation. - -### Posting a chat message - -Posting a chat message for given Chat id works like this: - -`POST /api/v1/pleroma/chats/:id/messages` - -Parameters: -- content: The text content of the message. Optional if media is attached. -- media_id: The id of an upload that will be attached to the message. - -Currently, no formatting beyond basic escaping and emoji is implemented. - -Returned data: - -```json -{ - "account_id": "someflakeid", - "chat_id": "1", - "content": "Check this out :firefox:", - "created_at": "2020-04-21T15:11:46.000Z", - "emojis": [ - { - "shortcode": "firefox", - "static_url": "https://dontbulling.me/emoji/Firefox.gif", - "url": "https://dontbulling.me/emoji/Firefox.gif", - "visible_in_picker": false - } - ], - "id": "13", - "unread": false -} -``` - -### Deleting a chat message - -Deleting a chat message for given Chat id works like this: - -`DELETE /api/v1/pleroma/chats/:chat_id/messages/:message_id` - -Returned data is the deleted message. - -### Notifications - -There's a new `pleroma:chat_mention` notification, which has this form. It is not given out in the notifications endpoint by default, you need to explicitly request it with `include_types[]=pleroma:chat_mention`: - -```json -{ - "id": "someid", - "type": "pleroma:chat_mention", - "account": { ... } // User account of the sender, - "chat_message": { - "chat_id": "1", - "id": "10", - "content": "Hello", - "account_id": "someflakeid", - "unread": false - }, - "created_at": "somedate" -} -``` - -### Streaming - -There is an additional `user:pleroma_chat` stream. Incoming chat messages will make the current chat be sent to this `user` stream. The `event` of an incoming chat message is `pleroma:chat_update`. The payload is the updated chat with the incoming chat message in the `last_message` field. - -### Web Push - -If you want to receive push messages for this type, you'll need to add the `pleroma:chat_mention` type to your alerts in the push subscription. diff --git a/docs/API/differences_in_mastoapi_responses.md b/docs/API/differences_in_mastoapi_responses.md deleted file mode 100644 index 84430408b..000000000 --- a/docs/API/differences_in_mastoapi_responses.md +++ /dev/null @@ -1,346 +0,0 @@ -# Differences in Mastodon API responses from vanilla Mastodon - -A Pleroma instance can be identified by " (compatible; Pleroma )" present in `version` field in response from `/api/v1/instance` - -## Flake IDs - -Pleroma uses 128-bit ids as opposed to Mastodon's 64 bits. However, just like Mastodon's ids, they are lexically sortable strings - -## Timelines - -Adding the parameter `with_muted=true` to the timeline queries will also return activities by muted (not by blocked!) users. - -Adding the parameter `exclude_visibilities` to the timeline queries will exclude the statuses with the given visibilities. The parameter accepts an array of visibility types (`public`, `unlisted`, `private`, `direct`), e.g., `exclude_visibilities[]=direct&exclude_visibilities[]=private`. - -Adding the parameter `reply_visibility` to the public and home timelines queries will filter replies. Possible values: without parameter (default) shows all replies, `following` - replies directed to you or users you follow, `self` - replies directed to you. - -Adding the parameter `instance=lain.com` to the public timeline will show only statuses originating from `lain.com` (or any remote instance). - -## Statuses - -- `visibility`: has additional possible values `list` and `local` (for local-only statuses) - -Has these additional fields under the `pleroma` object: - -- `local`: true if the post was made on the local instance -- `conversation_id`: the ID of the AP context the status is associated with (if any) -- `direct_conversation_id`: the ID of the Mastodon direct message conversation the status is associated with (if any) -- `in_reply_to_account_acct`: the `acct` property of User entity for replied user (if any) -- `content`: a map consisting of alternate representations of the `content` property with the key being its mimetype. Currently, the only alternate representation supported is `text/plain` -- `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being its mimetype. Currently, the only alternate representation supported is `text/plain` -- `expires_at`: a datetime (iso8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire -- `thread_muted`: true if the thread the post belongs to is muted -- `emoji_reactions`: A list with emoji / reaction maps. The format is `{name: "☕", count: 1, me: true}`. Contains no information about the reacting users, for that use the `/statuses/:id/reactions` endpoint. -- `parent_visible`: If the parent of this post is visible to the user or not. - -## Media Attachments - -Has these additional fields under the `pleroma` object: - -- `mime_type`: mime type of the attachment. - -### Attachment cap - -Some apps operate under the assumption that no more than 4 attachments can be returned or uploaded. Pleroma however does not enforce any limits on attachment count neither when returning the status object nor when posting. - -### Limitations - -Pleroma does not process remote images and therefore cannot include fields such as `meta` and `blurhash`. It does not support focal points or aspect ratios. The frontend is expected to handle it. - -## Accounts - -The `id` parameter can also be the `nickname` of the user. This only works in these endpoints, not the deeper nested ones for following etc. - -- `/api/v1/accounts/:id` -- `/api/v1/accounts/:id/statuses` - -Has these additional fields under the `pleroma` object: - -- `ap_id`: nullable URL string, ActivityPub id of the user -- `background_image`: nullable URL string, background image of the user -- `tags`: Lists an array of tags for the user -- `relationship` (object): Includes fields as documented for Mastodon API https://docs.joinmastodon.org/entities/relationship/ -- `is_moderator`: boolean, nullable, true if user is a moderator -- `is_admin`: boolean, nullable, true if user is an admin -- `confirmation_pending`: boolean, true if a new user account is waiting on email confirmation to be activated -- `hide_favorites`: boolean, true when the user has hiding favorites enabled -- `hide_followers`: boolean, true when the user has follower hiding enabled -- `hide_follows`: boolean, true when the user has follow hiding enabled -- `hide_followers_count`: boolean, true when the user has follower stat hiding enabled -- `hide_follows_count`: boolean, true when the user has follow stat hiding enabled -- `settings_store`: A generic map of settings for frontends. Opaque to the backend. Only returned in `/api/v1/accounts/verify_credentials` and `/api/v1/accounts/update_credentials` -- `chat_token`: The token needed for Pleroma chat. Only returned in `/api/v1/accounts/verify_credentials` -- `deactivated`: boolean, true when the user is deactivated -- `allow_following_move`: boolean, true when the user allows automatically follow moved following accounts -- `unread_conversation_count`: The count of unread conversations. Only returned to the account owner. -- `unread_notifications_count`: The count of unread notifications. Only returned to the account owner. -- `notification_settings`: object, can be absent. See `/api/pleroma/notification_settings` for the parameters/keys returned. -- `accepts_chat_messages`: boolean, but can be null if we don't have that information about a user -- `favicon`: nullable URL string, Favicon image of the user's instance - -### Source - -Has these additional fields under the `pleroma` object: - -- `show_role`: boolean, nullable, true when the user wants his role (e.g admin, moderator) to be shown -- `no_rich_text` - boolean, nullable, true when html tags are stripped from all statuses requested from the API -- `discoverable`: boolean, true when the user allows external services (search bots) etc. to index / list the account (regardless of this setting, user will still appear in regular search results) -- `actor_type`: string, the type of this account. - -## Conversations - -Has an additional field under the `pleroma` object: - -- `recipients`: The list of the recipients of this Conversation. These will be addressed when replying to this conversation. - -## GET `/api/v1/conversations` - -Accepts additional parameters: - -- `recipients`: Only return conversations with the given recipients (a list of user ids). Usage example: `GET /api/v1/conversations?recipients[]=1&recipients[]=2` - -## Account Search - -Behavior has changed: - -- `/api/v1/accounts/search`: Does not require authentication - -## Search (global) - -Unlisted posts are available in search results, they are considered to be public posts that shouldn't be shown in local/federated timeline. - -## Notifications - -Has these additional fields under the `pleroma` object: - -- `is_seen`: true if the notification was read by the user - -### Move Notification - -The `type` value is `move`. Has an additional field: - -- `target`: new account - -### EmojiReact Notification - -The `type` value is `pleroma:emoji_reaction`. Has these fields: - -- `emoji`: The used emoji -- `account`: The account of the user who reacted -- `status`: The status that was reacted on - -### ChatMention Notification (not default) - -This notification has to be requested explicitly. - -The `type` value is `pleroma:chat_mention` - -- `account`: The account who sent the message -- `chat_message`: The chat message - -### Report Notification (not default) - -This notification has to be requested explicitly. - -The `type` value is `pleroma:report` - -- `account`: The account who reported -- `report`: The report - -## GET `/api/v1/notifications` - -Accepts additional parameters: - -- `exclude_visibilities`: will exclude the notifications for activities with the given visibilities. The parameter accepts an array of visibility types (`public`, `unlisted`, `private`, `direct`). Usage example: `GET /api/v1/notifications?exclude_visibilities[]=direct&exclude_visibilities[]=private`. -- `include_types`: will include the notifications for activities with the given types. The parameter accepts an array of types (`mention`, `follow`, `reblog`, `favourite`, `move`, `pleroma:emoji_reaction`, `pleroma:chat_mention`, `pleroma:report`). Usage example: `GET /api/v1/notifications?include_types[]=mention&include_types[]=reblog`. - -## DELETE `/api/v1/notifications/destroy_multiple` - -An endpoint to delete multiple statuses by IDs. - -Required parameters: - -- `ids`: array of activity ids - -Usage example: `DELETE /api/v1/notifications/destroy_multiple/?ids[]=1&ids[]=2`. - -Returns on success: 200 OK `{}` - -## POST `/api/v1/statuses` - -Additional parameters can be added to the JSON body/Form data: - -- `preview`: boolean, if set to `true` the post won't be actually posted, but the status entity would still be rendered back. This could be useful for previewing rich text/custom emoji, for example. -- `content_type`: string, contain the MIME type of the status, it is transformed into HTML by the backend. You can get the list of the supported MIME types with the nodeinfo endpoint. -- `to`: A list of nicknames (like `lain@soykaf.club` or `lain` on the local server) that will be used to determine who is going to be addressed by this post. Using this will disable the implicit addressing by mentioned names in the `status` body, only the people in the `to` list will be addressed. The normal rules for post visibility are not affected by this and will still apply. -- `visibility`: string, besides standard MastoAPI values (`direct`, `private`, `unlisted`, `local` or `public`) it can be used to address a List by setting it to `list:LIST_ID`. -- `expires_in`: The number of seconds the posted activity should expire in. When a posted activity expires it will be deleted from the server, and a delete request for it will be federated. This needs to be longer than an hour. -- `in_reply_to_conversation_id`: Will reply to a given conversation, addressing only the people who are part of the recipient set of that conversation. Sets the visibility to `direct`. - -## GET `/api/v1/statuses` - -An endpoint to get multiple statuses by IDs. - -Required parameters: - -- `ids`: array of activity ids - -Usage example: `GET /api/v1/statuses/?ids[]=1&ids[]=2`. - -Returns: array of Status. - -The maximum number of statuses is limited to 100 per request. - -## PATCH `/api/v1/accounts/update_credentials` - -Additional parameters can be added to the JSON body/Form data: - -- `no_rich_text` - if true, html tags are stripped from all statuses requested from the API -- `hide_followers` - if true, user's followers will be hidden -- `hide_follows` - if true, user's follows will be hidden -- `hide_followers_count` - if true, user's follower count will be hidden -- `hide_follows_count` - if true, user's follow count will be hidden -- `hide_favorites` - if true, user's favorites timeline will be hidden -- `show_role` - if true, user's role (e.g admin, moderator) will be exposed to anyone in the API -- `default_scope` - the scope returned under `privacy` key in Source subentity -- `pleroma_settings_store` - Opaque user settings to be saved on the backend. -- `skip_thread_containment` - if true, skip filtering out broken threads -- `allow_following_move` - if true, allows automatically follow moved following accounts -- `also_known_as` - array of ActivityPub IDs, needed for following move -- `pleroma_background_image` - sets the background image of the user. Can be set to "" (an empty string) to reset. -- `discoverable` - if true, external services (search bots) etc. are allowed to index / list the account (regardless of this setting, user will still appear in regular search results). -- `actor_type` - the type of this account. -- `accepts_chat_messages` - if false, this account will reject all chat messages. - -All images (avatar, banner and background) can be reset to the default by sending an empty string ("") instead of a file. - -### Pleroma Settings Store - -Pleroma has mechanism that allows frontends to save blobs of json for each user on the backend. This can be used to save frontend-specific settings for a user that the backend does not need to know about. - -The parameter should have a form of `{frontend_name: {...}}`, with `frontend_name` identifying your type of client, e.g. `pleroma_fe`. It will overwrite everything under this property, but will not overwrite other frontend's settings. - -This information is returned in the `/api/v1/accounts/verify_credentials` endpoint. - -## Authentication - -*Pleroma supports refreshing tokens.* - -`POST /oauth/token` - -Post here request with `grant_type=refresh_token` to obtain new access token. Returns an access token. - -## Account Registration - -`POST /api/v1/accounts` - -Has these additional parameters (which are the same as in Pleroma-API): - -- `fullname`: optional -- `bio`: optional -- `captcha_solution`: optional, contains provider-specific captcha solution, -- `captcha_token`: optional, contains provider-specific captcha token -- `captcha_answer_data`: optional, contains provider-specific captcha data -- `token`: invite token required when the registrations aren't public. - -## Instance - -`GET /api/v1/instance` has additional fields - -- `max_toot_chars`: The maximum characters per post -- `chat_limit`: The maximum characters per chat message -- `description_limit`: The maximum characters per image description -- `poll_limits`: The limits of polls -- `upload_limit`: The maximum upload file size -- `avatar_upload_limit`: The same for avatars -- `background_upload_limit`: The same for backgrounds -- `banner_upload_limit`: The same for banners -- `background_image`: A background image that frontends can use -- `pleroma.metadata.features`: A list of supported features -- `pleroma.metadata.federation`: The federation restrictions of this instance -- `pleroma.metadata.fields_limits`: A list of values detailing the length and count limitation for various instance-configurable fields. -- `pleroma.metadata.post_formats`: A list of the allowed post format types -- `vapid_public_key`: The public key needed for push messages - -## Push Subscription - -`POST /api/v1/push/subscription` -`PUT /api/v1/push/subscription` - -Permits these additional alert types: - -- pleroma:chat_mention -- pleroma:emoji_reaction - -## Markers - -Has these additional fields under the `pleroma` object: - -- `unread_count`: contains number unread notifications - -## Streaming - -### Chats - -There is an additional `user:pleroma_chat` stream. Incoming chat messages will make the current chat be sent to this `user` stream. The `event` of an incoming chat message is `pleroma:chat_update`. The payload is the updated chat with the incoming chat message in the `last_message` field. - -### Remote timelines - -For viewing remote server timelines, there are `public:remote` and `public:remote:media` streams. Each of these accept a parameter like `?instance=lain.com`. - -### Follow relationships updates - -Pleroma streams follow relationships updates as `pleroma:follow_relationships_update` events to the `user` stream. - -The message payload consist of: - -- `state`: a relationship state, one of `follow_pending`, `follow_accept` or `follow_reject`. - -- `follower` and `following` maps with following fields: - - `id`: user ID - - `follower_count`: follower count - - `following_count`: following count - -## User muting and thread muting - -Both user muting and thread muting can be done for only a certain time by adding an `expires_in` parameter to the API calls and giving the expiration time in seconds. - -## Not implemented - -Pleroma is generally compatible with the Mastodon 2.7.2 API, but some newer features and non-essential features are omitted. These features usually return an HTTP 200 status code, but with an empty response. While they may be added in the future, they are considered low priority. - -### Suggestions - -*Added in Mastodon 2.4.3* - -- `GET /api/v1/suggestions`: Returns an empty array, `[]` - -### Trends - -*Added in Mastodon 3.0.0* - -- `GET /api/v1/trends`: Returns an empty array, `[]` - -### Identity proofs - -*Added in Mastodon 2.8.0* - -- `GET /api/v1/identity_proofs`: Returns an empty array, `[]` - -### Endorsements - -*Added in Mastodon 2.5.0* - -- `GET /api/v1/endorsements`: Returns an empty array, `[]` - -### Profile directory - -*Added in Mastodon 3.0.0* - -- `GET /api/v1/directory`: Returns HTTP 404 - -### Featured tags - -*Added in Mastodon 3.0.0* - -- `GET /api/v1/featured_tags`: Returns HTTP 404 diff --git a/docs/API/pleroma_api.md b/docs/API/pleroma_api.md deleted file mode 100644 index d8790ca32..000000000 --- a/docs/API/pleroma_api.md +++ /dev/null @@ -1,655 +0,0 @@ -# Pleroma API - -Requests that require it can be authenticated with [an OAuth token](https://tools.ietf.org/html/rfc6749), the `_pleroma_key` cookie, or [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization). - -Request parameters can be passed via [query strings](https://en.wikipedia.org/wiki/Query_string) or as [form data](https://www.w3.org/TR/html401/interact/forms.html). Files must be uploaded as `multipart/form-data`. - -## `/api/pleroma/emoji` -### Lists the custom emoji on that server. -* Method: `GET` -* Authentication: not required -* Params: none -* Response: JSON -* Example response: -```json -{ - "girlpower": { - "tags": [ - "Finmoji" - ], - "image_url": "/finmoji/128px/girlpower-128.png" - }, - "education": { - "tags": [ - "Finmoji" - ], - "image_url": "/finmoji/128px/education-128.png" - }, - "finnishlove": { - "tags": [ - "Finmoji" - ], - "image_url": "/finmoji/128px/finnishlove-128.png" - } -} -``` -* Note: Same data as Mastodon API’s `/api/v1/custom_emojis` but in a different format - -## `/api/pleroma/follow_import` -### Imports your follows, for example from a Mastodon CSV file. -* Method: `POST` -* Authentication: required -* Params: - * `list`: STRING or FILE containing a whitespace-separated list of accounts to follow -* Response: HTTP 200 on success, 500 on error -* Note: Users that can't be followed are silently skipped. - -## `/api/pleroma/blocks_import` -### Imports your blocks. -* Method: `POST` -* Authentication: required -* Params: - * `list`: STRING or FILE containing a whitespace-separated list of accounts to block -* Response: HTTP 200 on success, 500 on error - -## `/api/pleroma/mutes_import` -### Imports your mutes. -* Method: `POST` -* Authentication: required -* Params: - * `list`: STRING or FILE containing a whitespace-separated list of accounts to mute -* Response: HTTP 200 on success, 500 on error - -## `/api/pleroma/captcha` -### Get a new captcha -* Method: `GET` -* Authentication: not required -* Params: none -* Response: Provider specific JSON, the only guaranteed parameter is `type` -* Example response: `{"type": "kocaptcha", "token": "whatever", "url": "https://captcha.kotobank.ch/endpoint", "seconds_valid": 300}` - -## `/api/pleroma/delete_account` -### Delete an account -* Method `POST` -* Authentication: required -* Params: - * `password`: user's password -* Response: JSON. Returns `{"status": "success"}` if the deletion was successful, `{"error": "[error message]"}` otherwise -* Example response: `{"error": "Invalid password."}` - -## `/api/pleroma/disable_account` -### Disable an account -* Method `POST` -* Authentication: required -* Params: - * `password`: user's password -* Response: JSON. Returns `{"status": "success"}` if the account was successfully disabled, `{"error": "[error message]"}` otherwise -* Example response: `{"error": "Invalid password."}` - -## `/api/pleroma/accounts/mfa` -#### Gets current MFA settings -* method: `GET` -* Authentication: required -* OAuth scope: `read:security` -* Response: JSON. Returns `{"enabled": "false", "totp": false }` - -## `/api/pleroma/accounts/mfa/setup/totp` -#### Pre-setup the MFA/TOTP method -* method: `GET` -* Authentication: required -* OAuth scope: `write:security` -* Response: JSON. Returns `{"key": [secret_key], "provisioning_uri": "[qr code uri]" }` when successful, otherwise returns HTTP 422 `{"error": "error_msg"}` - -## `/api/pleroma/accounts/mfa/confirm/totp` -#### Confirms & enables MFA/TOTP support for user account. -* method: `POST` -* Authentication: required -* OAuth scope: `write:security` -* Params: - * `password`: user's password - * `code`: token from TOTP App -* Response: JSON. Returns `{}` if the enable was successful, HTTP 422 `{"error": "[error message]"}` otherwise - - -## `/api/pleroma/accounts/mfa/totp` -#### Disables MFA/TOTP method for user account. -* method: `DELETE` -* Authentication: required -* OAuth scope: `write:security` -* Params: - * `password`: user's password -* Response: JSON. Returns `{}` if the disable was successful, HTTP 422 `{"error": "[error message]"}` otherwise -* Example response: `{"error": "Invalid password."}` - -## `/api/pleroma/accounts/mfa/backup_codes` -#### Generstes backup codes MFA for user account. -* method: `GET` -* Authentication: required -* OAuth scope: `write:security` -* Response: JSON. Returns `{"codes": codes}`when successful, otherwise HTTP 422 `{"error": "[error message]"}` - -## `/api/pleroma/admin/` -See [Admin-API](admin_api.md) - -## `/api/v1/pleroma/notifications/read` -### Mark notifications as read -* Method `POST` -* Authentication: required -* Params (mutually exclusive): - * `id`: a single notification id to read - * `max_id`: read all notifications up to this id -* Response: Notification entity/Array of Notification entities that were read. In case of `max_id`, only the first 80 read notifications will be returned. - -## `/api/v1/pleroma/accounts/:id/subscribe` -### Subscribe to receive notifications for all statuses posted by a user -* Method `POST` -* Authentication: required -* Params: - * `id`: account id to subscribe to -* Response: JSON, returns a mastodon relationship object on success, otherwise returns `{"error": "error_msg"}` -* Example response: -```json -{ - "id": "abcdefg", - "following": true, - "followed_by": false, - "blocking": false, - "muting": false, - "muting_notifications": false, - "subscribing": true, - "requested": false, - "domain_blocking": false, - "showing_reblogs": true, - "endorsed": false -} -``` - -## `/api/v1/pleroma/accounts/:id/unsubscribe` -### Unsubscribe to stop receiving notifications from user statuses -* Method `POST` -* Authentication: required -* Params: - * `id`: account id to unsubscribe from -* Response: JSON, returns a mastodon relationship object on success, otherwise returns `{"error": "error_msg"}` -* Example response: -```json -{ - "id": "abcdefg", - "following": true, - "followed_by": false, - "blocking": false, - "muting": false, - "muting_notifications": false, - "subscribing": false, - "requested": false, - "domain_blocking": false, - "showing_reblogs": true, - "endorsed": false -} -``` - -## `/api/v1/pleroma/accounts/:id/favourites` -### Returns favorites timeline of any user -* Method `GET` -* Authentication: not required -* Params: - * `id`: the id of the account for whom to return results - * `limit`: optional, the number of records to retrieve - * `since_id`: optional, returns results that are more recent than the specified id - * `max_id`: optional, returns results that are older than the specified id -* Response: JSON, returns a list of Mastodon Status entities on success, otherwise returns `{"error": "error_msg"}` -* Example response: -```json -[ - { - "account": { - "id": "9hptFmUF3ztxYh3Svg", - "url": "https://pleroma.example.org/users/nick2", - "username": "nick2", - ... - }, - "application": {"name": "Web", "website": null}, - "bookmarked": false, - "card": null, - "content": "This is :moominmamma: note 0", - "created_at": "2019-04-15T15:42:15.000Z", - "emojis": [], - "favourited": false, - "favourites_count": 1, - "id": "9hptFmVJ02khbzYJaS", - "in_reply_to_account_id": null, - "in_reply_to_id": null, - "language": null, - "media_attachments": [], - "mentions": [], - "muted": false, - "pinned": false, - "pleroma": { - "content": {"text/plain": "This is :moominmamma: note 0"}, - "conversation_id": 13679, - "local": true, - "spoiler_text": {"text/plain": "2hu"} - }, - "reblog": null, - "reblogged": false, - "reblogs_count": 0, - "replies_count": 0, - "sensitive": false, - "spoiler_text": "2hu", - "tags": [{"name": "2hu", "url": "/tag/2hu"}], - "uri": "https://pleroma.example.org/objects/198ed2a1-7912-4482-b559-244a0369e984", - "url": "https://pleroma.example.org/notice/9hptFmVJ02khbzYJaS", - "visibility": "public" - } -] -``` - -## `/api/v1/pleroma/accounts/update_*` -### Set and clear account avatar, banner, and background - -- PATCH `/api/v1/pleroma/accounts/update_avatar`: Set/clear user avatar image -- PATCH `/api/v1/pleroma/accounts/update_banner`: Set/clear user banner image -- PATCH `/api/v1/pleroma/accounts/update_background`: Set/clear user background image - -## `/api/v1/pleroma/accounts/confirmation_resend` -### Resend confirmation email -* Method `POST` -* Params: - * `email`: email of that needs to be verified -* Authentication: not required -* Response: 204 No Content - -## `/api/v1/pleroma/mascot` -### Gets user mascot image -* Method `GET` -* Authentication: required - -* Response: JSON. Returns a mastodon media attachment entity. -* Example response: -```json -{ - "id": "abcdefg", - "url": "https://pleroma.example.org/media/abcdefg.png", - "type": "image", - "pleroma": { - "mime_type": "image/png" - } -} -``` - -### Updates user mascot image -* Method `PUT` -* Authentication: required -* Params: - * `file`: Multipart image -* Response: JSON. Returns a mastodon media attachment entity - when successful, otherwise returns HTTP 415 `{"error": "error_msg"}` -* Example response: -```json -{ - "id": "abcdefg", - "url": "https://pleroma.example.org/media/abcdefg.png", - "type": "image", - "pleroma": { - "mime_type": "image/png" - } -} -``` -* Note: Behaves exactly the same as `POST /api/v1/upload`. - Can only accept images - any attempt to upload non-image files will be met with `HTTP 415 Unsupported Media Type`. - -## `/api/pleroma/notification_settings` -### Updates user notification settings -* Method `PUT` -* Authentication: required -* Params: - * `block_from_strangers`: BOOLEAN field, blocks notifications from accounts you do not follow - * `hide_notification_contents`: BOOLEAN field. When set to true, it removes the contents of a message from the push notification. -* Response: JSON. Returns `{"status": "success"}` if the update was successful, otherwise returns `{"error": "error_msg"}` - -## `/api/pleroma/healthcheck` -### Healthcheck endpoint with additional system data. -* Method `GET` -* Authentication: not required -* Params: none -* Response: JSON, statuses (200 - healthy, 503 unhealthy). -* Example response: -```json -{ - "pool_size": 0, # database connection pool - "active": 0, # active processes - "idle": 0, # idle processes - "memory_used": 0.00, # Memory used - "healthy": true, # Instance state - "job_queue_stats": {} # Job queue stats -} -``` - -## `/api/pleroma/change_email` -### Change account email -* Method `POST` -* Authentication: required -* Params: - * `password`: user's password - * `email`: new email -* Response: JSON. Returns `{"status": "success"}` if the change was successful, `{"error": "[error message]"}` otherwise -* Note: Currently, Mastodon has no API for changing email. If they add it in future it might be incompatible with Pleroma. - -# Pleroma Conversations - -Pleroma Conversations have the same general structure that Mastodon Conversations have. The behavior differs in the following ways when using these endpoints: - -1. Pleroma Conversations never add or remove recipients, unless explicitly changed by the user. -2. Pleroma Conversations statuses can be requested by Conversation id. -3. Pleroma Conversations can be replied to. - -Conversations have the additional field `recipients` under the `pleroma` key. This holds a list of all the accounts that will receive a message in this conversation. - -The status posting endpoint takes an additional parameter, `in_reply_to_conversation_id`, which, when set, will set the visiblity to direct and address only the people who are the recipients of that Conversation. - -⚠ Conversation IDs can be found in direct messages with the `pleroma.direct_conversation_id` key, do not confuse it with `pleroma.conversation_id`. - -## `GET /api/v1/pleroma/conversations/:id/statuses` -### Timeline for a given conversation -* Method `GET` -* Authentication: required -* Params: Like other timelines -* Response: JSON, statuses (200 - healthy, 503 unhealthy). - -## `GET /api/v1/pleroma/conversations/:id` -### The conversation with the given ID. -* Method `GET` -* Authentication: required -* Params: None -* Response: JSON, statuses (200 - healthy, 503 unhealthy). - -## `PATCH /api/v1/pleroma/conversations/:id` -### Update a conversation. Used to change the set of recipients. -* Method `PATCH` -* Authentication: required -* Params: - * `recipients`: A list of ids of users that should receive posts to this conversation. This will replace the current list of recipients, so submit the full list. The owner of owner of the conversation will always be part of the set of recipients, though. -* Response: JSON, statuses (200 - healthy, 503 unhealthy) - -## `POST /api/v1/pleroma/conversations/read` -### Marks all user's conversations as read. -* Method `POST` -* Authentication: required -* Params: None -* Response: JSON, returns a list of Mastodon Conversation entities that were marked as read (200 - healthy, 503 unhealthy). - -## `GET /api/pleroma/emoji/pack?name=:name` - -### Get pack.json for the pack - -* Method `GET` -* Authentication: not required -* Params: - * `page`: page number for files (default 1) - * `page_size`: page size for files (default 30) -* Response: JSON, pack json with `files`, `files_count` and `pack` keys with 200 status or 404 if the pack does not exist. - -```json -{ - "files": {...}, - "files_count": 0, // emoji count in pack - "pack": {...} -} -``` - -## `POST /api/pleroma/emoji/pack?name=:name` - -### Creates an empty pack - -* Method `POST` -* Authentication: required (admin) -* Params: - * `name`: pack name -* Response: JSON, "ok" and 200 status or 409 if the pack with that name already exists - -## `PATCH /api/pleroma/emoji/pack?name=:name` - -### Updates (replaces) pack metadata - -* Method `PATCH` -* Authentication: required (admin) -* Params: - * `name`: pack name - * `metadata`: metadata to replace the old one - * `license`: Pack license - * `homepage`: Pack home page url - * `description`: Pack description - * `fallback-src`: Fallback url to download pack from - * `fallback-src-sha256`: SHA256 encoded for fallback pack archive - * `share-files`: is pack allowed for sharing (boolean) -* Response: JSON, updated "metadata" section of the pack and 200 status or 400 if there was a - problem with the new metadata (the error is specified in the "error" part of the response JSON) - -## `DELETE /api/pleroma/emoji/pack?name=:name` - -### Delete a custom emoji pack - -* Method `DELETE` -* Authentication: required (admin) -* Params: - * `name`: pack name -* Response: JSON, "ok" and 200 status or 500 if there was an error deleting the pack - -## `GET /api/pleroma/emoji/packs/import` - -### Imports packs from filesystem - -* Method `GET` -* Authentication: required (admin) -* Params: None -* Response: JSON, returns a list of imported packs. - -## `GET /api/pleroma/emoji/packs/remote` - -### Make request to another instance for packs list - -* Method `GET` -* Authentication: required (admin) -* Params: - * `url`: url of the instance to get packs from - * `page`: page number for packs (default 1) - * `page_size`: page size for packs (default 50) -* Response: JSON with the pack list, hashmap with pack name and pack contents - -## `POST /api/pleroma/emoji/packs/download` - -### Download pack from another instance - -* Method `POST` -* Authentication: required (admin) -* Params: - * `url`: url of the instance to download from - * `name`: pack to download from that instance - * `as`: (*optional*) name how to save pack -* Response: JSON, "ok" with 200 status if the pack was downloaded, or 500 if there were - errors downloading the pack - -## `POST /api/pleroma/emoji/packs/files?name=:name` - -### Add new file to the pack - -* Method `POST` -* Authentication: required (admin) -* Params: - * `name`: pack name - * `file`: file needs to be uploaded with the multipart request or link to remote file. - * `shortcode`: (*optional*) shortcode for new emoji, must be unique for all emoji. If not sended, shortcode will be taken from original filename. - * `filename`: (*optional*) new emoji file name. If not specified will be taken from original filename. -* Response: JSON, list of files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message. - -## `PATCH /api/pleroma/emoji/packs/files?name=:name` - -### Update emoji file from pack - -* Method `PATCH` -* Authentication: required (admin) -* Params: - * `name`: pack name - * `shortcode`: emoji file shortcode - * `new_shortcode`: new emoji file shortcode - * `new_filename`: new filename for emoji file - * `force`: (*optional*) with true value to overwrite existing emoji with new shortcode -* Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message. - -## `DELETE /api/pleroma/emoji/packs/files?name=:name` - -### Delete emoji file from pack - -* Method `DELETE` -* Authentication: required (admin) -* Params: - * `name`: pack name - * `shortcode`: emoji file shortcode -* Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message. - -## `GET /api/pleroma/emoji/packs` - -### Lists local custom emoji packs - -* Method `GET` -* Authentication: not required -* Params: - * `page`: page number for packs (default 1) - * `page_size`: page size for packs (default 50) -* Response: `packs` key with JSON hashmap of pack name to pack contents and `count` key for count of packs. - -```json -{ - "packs": { - "pack_name": {...}, // pack contents - ... - }, - "count": 0 // packs count -} -``` - -## `GET /api/pleroma/emoji/packs/archive?name=:name` - -### Requests a local pack archive from the instance - -* Method `GET` -* Authentication: not required -* Params: - * `name`: pack name -* Response: the archive of the pack with a 200 status code, 403 if the pack is not set as shared, - 404 if the pack does not exist - -## `GET /api/v1/pleroma/accounts/:id/scrobbles` -### Requests a list of current and recent Listen activities for an account -* Method `GET` -* Authentication: not required -* Params: None -* Response: An array of media metadata entities. -* Example response: -```json -[ - { - "account": {...}, - "id": "1234", - "title": "Some Title", - "artist": "Some Artist", - "album": "Some Album", - "length": 180000, - "created_at": "2019-09-28T12:40:45.000Z" - } -] -``` - -## `POST /api/v1/pleroma/scrobble` -### Creates a new Listen activity for an account -* Method `POST` -* Authentication: required -* Params: - * `title`: the title of the media playing - * `album`: the album of the media playing [optional] - * `artist`: the artist of the media playing [optional] - * `length`: the length of the media playing [optional] -* Response: the newly created media metadata entity representing the Listen activity - -# Emoji Reactions - -Emoji reactions work a lot like favourites do. They make it possible to react to a post with a single emoji character. To detect the presence of this feature, you can check `pleroma_emoji_reactions` entry in the features list of nodeinfo. - -## `PUT /api/v1/pleroma/statuses/:id/reactions/:emoji` -### React to a post with a unicode emoji -* Method: `PUT` -* Authentication: required -* Params: `emoji`: A unicode RGI emoji or a regional indicator -* Response: JSON, the status. - -## `DELETE /api/v1/pleroma/statuses/:id/reactions/:emoji` -### Remove a reaction to a post with a unicode emoji -* Method: `DELETE` -* Authentication: required -* Params: `emoji`: A unicode RGI emoji or a regional indicator -* Response: JSON, the status. - -## `GET /api/v1/pleroma/statuses/:id/reactions` -### Get an object of emoji to account mappings with accounts that reacted to the post -* Method: `GET` -* Authentication: optional -* Params: None -* Response: JSON, a list of emoji/account list tuples, sorted by emoji insertion date, in ascending order, e.g, the first emoji in the list is the oldest. -* Example Response: -```json -[ - {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]}, - {"name": "☕", "count": 1, "me": false, "accounts": [{"id" => "abc..."}]} -] -``` - -## `GET /api/v1/pleroma/statuses/:id/reactions/:emoji` -### Get an object of emoji to account mappings with accounts that reacted to the post for a specific emoji -* Method: `GET` -* Authentication: optional -* Params: None -* Response: JSON, a list of emoji/account list tuples -* Example Response: -```json -[ - {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]} -] -``` - -## `POST /api/v1/pleroma/backups` -### Create a user backup archive - -* Method: `POST` -* Authentication: required -* Params: none -* Response: JSON -* Example response: - -```json -[{ - "content_type": "application/zip", - "file_size": 0, - "inserted_at": "2020-09-10T16:18:03.000Z", - "processed": false, - "url": "https://example.com/media/backups/archive-foobar-20200910T161803-QUhx6VYDRQ2wfV0SdA2Pfj_2CLM_ATUlw-D5l5TJf4Q.zip" -}] -``` - -## `GET /api/v1/pleroma/backups` -### Lists user backups - -* Method: `GET` -* Authentication: not required -* Params: none -* Response: JSON -* Example response: - -```json -[{ - "content_type": "application/zip", - "file_size": 55457, - "inserted_at": "2020-09-10T16:18:03.000Z", - "processed": true, - "url": "https://example.com/media/backups/archive-foobar-20200910T161803-QUhx6VYDRQ2wfV0SdA2Pfj_2CLM_ATUlw-D5l5TJf4Q.zip" -}] -``` diff --git a/docs/API/prometheus.md b/docs/API/prometheus.md deleted file mode 100644 index a5158d905..000000000 --- a/docs/API/prometheus.md +++ /dev/null @@ -1,44 +0,0 @@ -# Prometheus Metrics - -Pleroma includes support for exporting metrics via the [prometheus_ex](https://github.com/deadtrickster/prometheus.ex) library. - -Config example: - -``` -config :prometheus, Pleroma.Web.Endpoint.MetricsExporter, - enabled: true, - auth: {:basic, "myusername", "mypassword"}, - ip_whitelist: ["127.0.0.1"], - path: "/api/pleroma/app_metrics", - format: :text -``` - -* `enabled` (Pleroma extension) enables the endpoint -* `ip_whitelist` (Pleroma extension) could be used to restrict access only to specified IPs -* `auth` sets the authentication (`false` for no auth; configurable to HTTP Basic Auth, see [prometheus-plugs](https://github.com/deadtrickster/prometheus-plugs#exporting) documentation) -* `format` sets the output format (`:text` or `:protobuf`) -* `path` sets the path to app metrics page - - -## `/api/pleroma/app_metrics` - -### Exports Prometheus application metrics - -* Method: `GET` -* Authentication: not required by default (see configuration options above) -* Params: none -* Response: text - -## Grafana - -### Config example - -The following is a config example to use with [Grafana](https://grafana.com) - -``` - - job_name: 'beam' - metrics_path: /api/pleroma/app_metrics - scheme: https - static_configs: - - targets: ['pleroma.soykaf.com'] -``` diff --git a/docs/ap_extensions.md b/docs/ap_extensions.md deleted file mode 100644 index 3d1caeb3e..000000000 --- a/docs/ap_extensions.md +++ /dev/null @@ -1,65 +0,0 @@ -# AP Extensions -## Actor endpoints - -The following endpoints are additionally present into our actors. - -- `oauthRegistrationEndpoint` (`http://litepub.social/ns#oauthRegistrationEndpoint`) -- `uploadMedia` (`https://www.w3.org/ns/activitystreams#uploadMedia`) - -### oauthRegistrationEndpoint - -Points to MastodonAPI `/api/v1/apps` for now. - -See - -### uploadMedia - -Inspired by , it is part of the ActivityStreams namespace because it used to be part of the ActivityPub specification and got removed from it. - -Content-Type: multipart/form-data - -Parameters: -- (required) `file`: The file being uploaded -- (optionnal) `description`: A plain-text description of the media, for accessibility purposes. - -Response: HTTP 201 Created with the object into the body, no `Location` header provided as it doesn't have an `id` - -The object given in the reponse should then be inserted into an Object's `attachment` field. - -## ChatMessages - -`ChatMessage`s are the messages sent in 1-on-1 chats. They are similar to -`Note`s, but the addresing is done by having a single AP actor in the `to` -field. Addressing multiple actors is not allowed. These messages are always -private, there is no public version of them. They are created with a `Create` -activity. - -They are part of the `litepub` namespace as `http://litepub.social/ns#ChatMessage`. - -Example: - -```json -{ - "actor": "http://2hu.gensokyo/users/raymoo", - "id": "http://2hu.gensokyo/objects/1", - "object": { - "attributedTo": "http://2hu.gensokyo/users/raymoo", - "content": "You expected a cute girl? Too bad.", - "id": "http://2hu.gensokyo/objects/2", - "published": "2020-02-12T14:08:20Z", - "to": [ - "http://2hu.gensokyo/users/marisa" - ], - "type": "ChatMessage" - }, - "published": "2018-02-12T14:08:20Z", - "to": [ - "http://2hu.gensokyo/users/marisa" - ], - "type": "Create" -} -``` - -This setup does not prevent multi-user chats, but these will have to go through -a `Group`, which will be the recipient of the messages and then `Announce` them -to the users in the `Group`. diff --git a/docs/configuration/mrf.md b/docs/configuration/mrf.md index 31c66e098..9e8c0a2d7 100644 --- a/docs/configuration/mrf.md +++ b/docs/configuration/mrf.md @@ -133,3 +133,26 @@ config :pleroma, :mrf, ``` Please note that the Pleroma developers consider custom MRF policy modules to fall under the purview of the AGPL. As such, you are obligated to release the sources to your custom MRF policy modules upon request. + +### MRF policies descriptions + +If MRF policy depends on config, it can be added into MRF tab to adminFE by adding `config_description/0` method, which returns a map with a specific structure. See existing MRF's like `lib/pleroma/web/activity_pub/mrf/activity_expiration_policy.ex` for examples. Note that more complex inputs, like tuples or maps, may need extra changes in the adminFE and just adding it to `config_description/0` may not be enough to get these inputs working from the adminFE. + +Example: + +```elixir +%{ + key: :mrf_activity_expiration, + related_policy: "Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy", + label: "MRF Activity Expiration Policy", + description: "Adds automatic expiration to all local activities", + children: [ + %{ + key: :days, + type: :integer, + description: "Default global expiration time for all local activities (in days)", + suggestions: [90, 365] + } + ] + } +``` diff --git a/docs/dev.md b/docs/dev.md deleted file mode 100644 index 765380a58..000000000 --- a/docs/dev.md +++ /dev/null @@ -1,46 +0,0 @@ -This document contains notes and guidelines for Pleroma developers. - -# Authentication & Authorization - -## OAuth token-based authentication & authorization - -* Pleroma supports hierarchical OAuth scopes, just like Mastodon but with added granularity of admin scopes. For a reference, see [Mastodon OAuth scopes](https://docs.joinmastodon.org/api/oauth-scopes/). - -* It is important to either define OAuth scope restrictions or explicitly mark OAuth scope check as skipped, for every controller action. To define scopes, call `plug(Pleroma.Web.Plugs.OAuthScopesPlug, %{scopes: [...]})`. To explicitly set OAuth scopes check skipped, call `plug(:skip_plug, Pleroma.Web.Plugs.OAuthScopesPlug )`. - -* In controllers, `use Pleroma.Web, :controller` will result in `action/2` (see `Pleroma.Web.controller/0` for definition) be called prior to actual controller action, and it'll perform security / privacy checks before passing control to actual controller action. - - For routes with `:authenticated_api` pipeline, authentication & authorization are expected, thus `OAuthScopesPlug` will be run unless explicitly skipped (also `EnsureAuthenticatedPlug` will be executed immediately before action even if there was an early run to give an early error, since `OAuthScopesPlug` supports `:proceed_unauthenticated` option, and other plugs may support similar options as well). - - For `:api` pipeline routes, it'll be verified whether `OAuthScopesPlug` was called or explicitly skipped, and if it was not then auth information will be dropped for request. Then `EnsurePublicOrAuthenticatedPlug` will be called to ensure that either the instance is not private or user is authenticated (unless explicitly skipped). Such automated checks help to prevent human errors and result in higher security / privacy for users. - -## Non-OAuth authentication - -* With non-OAuth authentication ([HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization) or HTTP header- or params-provided auth), OAuth scopes check is _not_ performed for any action (since password is provided during the auth, requester is able to obtain a token with full permissions anyways); auth plugs invoke `Pleroma.Helpers.AuthHelper.skip_oauth(conn)` in this case. - -## Auth-related configuration, OAuth consumer mode etc. - -See `Authentication` section of [the configuration cheatsheet](configuration/cheatsheet.md#authentication). - -## MRF policies descriptions - -If MRF policy depends on config, it can be added into MRF tab to adminFE by adding `config_description/0` method, which returns map with special structure. - -Example: - -```elixir -%{ - key: :mrf_activity_expiration, - related_policy: "Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy", - label: "MRF Activity Expiration Policy", - description: "Adds automatic expiration to all local activities", - children: [ - %{ - key: :days, - type: :integer, - description: "Default global expiration time for all local activities (in days)", - suggestions: [90, 365] - } - ] - } -``` diff --git a/docs/development/API/admin_api.md b/docs/development/API/admin_api.md new file mode 100644 index 000000000..5253dc668 --- /dev/null +++ b/docs/development/API/admin_api.md @@ -0,0 +1,1565 @@ +# Admin API + +Authentication is required and the user must be an admin. + +Configuration options: + +* `[:auth, :enforce_oauth_admin_scope_usage]` — OAuth admin scope requirement toggle. + If `true`, admin actions explicitly demand admin OAuth scope(s) presence in OAuth token (client app must support admin scopes). + If `false` and token doesn't have admin scope(s), `is_admin` user flag grants access to admin-specific actions. + Note that client app needs to explicitly support admin scopes and request them when obtaining auth token. + +## `GET /api/pleroma/admin/users` + +### List users + +- Query Params: + - *optional* `query`: **string** search term (e.g. nickname, domain, nickname@domain) + - *optional* `filters`: **string** comma-separated string of filters: + - `local`: only local users + - `external`: only external users + - `active`: only active users + - `need_approval`: only unapproved users + - `unconfirmed`: only unconfirmed users + - `deactivated`: only deactivated users + - `is_admin`: users with admin role + - `is_moderator`: users with moderator role + - *optional* `page`: **integer** page number + - *optional* `page_size`: **integer** number of users per page (default is `50`) + - *optional* `tags`: **[string]** tags list + - *optional* `actor_types`: **[string]** actor type list (`Person`, `Service`, `Application`) + - *optional* `name`: **string** user display name + - *optional* `email`: **string** user email +- Example: `https://mypleroma.org/api/pleroma/admin/users?query=john&filters=local,active&page=1&page_size=10&tags[]=some_tag&tags[]=another_tag&name=display_name&email=email@example.com` +- Response: + +```json +{ + "page_size": integer, + "count": integer, + "users": [ + { + "deactivated": bool, + "id": integer, + "nickname": string, + "roles": { + "admin": bool, + "moderator": bool + }, + "local": bool, + "tags": array, + "avatar": string, + "display_name": string, + "confirmation_pending": bool, + "approval_pending": bool, + "registration_reason": string, + }, + ... + ] +} +``` + +## DEPRECATED `DELETE /api/pleroma/admin/users` + +### Remove a user + +- Params: + - `nickname` +- Response: User’s nickname + +## `DELETE /api/pleroma/admin/users` + +### Remove a user + +- Params: + - `nicknames` +- Response: Array of user nicknames + +### Create a user + +- Method: `POST` +- Params: + `users`: [ + { + `nickname`, + `email`, + `password` + } + ] +- Response: User’s nickname + +## `POST /api/pleroma/admin/users/follow` + +### Make a user follow another user + +- Params: + - `follower`: The nickname of the follower + - `followed`: The nickname of the followed +- Response: + - "ok" + +## `POST /api/pleroma/admin/users/unfollow` + +### Make a user unfollow another user + +- Params: + - `follower`: The nickname of the follower + - `followed`: The nickname of the followed +- Response: + - "ok" + +## `PATCH /api/pleroma/admin/users/:nickname/toggle_activation` + +### Toggle user activation + +- Params: + - `nickname` +- Response: User’s object + +```json +{ + "deactivated": bool, + "id": integer, + "nickname": string +} +``` + +## `PUT /api/pleroma/admin/users/tag` + +### Tag a list of users + +- Params: + - `nicknames` (array) + - `tags` (array) + +## `DELETE /api/pleroma/admin/users/tag` + +### Untag a list of users + +- Params: + - `nicknames` (array) + - `tags` (array) + +## `GET /api/pleroma/admin/users/:nickname/permission_group` + +### Get user user permission groups membership + +- Params: none +- Response: + +```json +{ + "is_moderator": bool, + "is_admin": bool +} +``` + +## `GET /api/pleroma/admin/users/:nickname/permission_group/:permission_group` + +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 per permission group + +- Params: none +- Response: + +```json +{ + "is_moderator": bool, + "is_admin": bool +} +``` + +## DEPRECATED `POST /api/pleroma/admin/users/:nickname/permission_group/:permission_group` + +### Add user to permission group + +- Params: none +- Response: + - On failure: `{"error": "…"}` + - On success: JSON of the user + +## `POST /api/pleroma/admin/users/permission_group/:permission_group` + +### Add users to permission group + +- Params: + - `nicknames`: nicknames array +- Response: + - On failure: `{"error": "…"}` + - On success: JSON of the user + +## DEPRECATED `DELETE /api/pleroma/admin/users/:nickname/permission_group/:permission_group` + +## `DELETE /api/pleroma/admin/users/:nickname/permission_group/:permission_group` + +### Remove user from permission group + +- Params: none +- Response: + - On failure: `{"error": "…"}` + - On success: JSON of the user +- Note: An admin cannot revoke their own admin status. + +## `DELETE /api/pleroma/admin/users/permission_group/:permission_group` + +### Remove users from permission group + +- Params: + - `nicknames`: nicknames array +- Response: + - On failure: `{"error": "…"}` + - On success: JSON of the user +- Note: An admin cannot revoke their own admin status. + +## `PATCH /api/pleroma/admin/users/activate` + +### Activate user + +- Params: + - `nicknames`: nicknames array +- Response: + +```json +{ + users: [ + { + // user object + } + ] +} +``` + +## `PATCH /api/pleroma/admin/users/deactivate` + +### Deactivate user + +- Params: + - `nicknames`: nicknames array +- Response: + +```json +{ + users: [ + { + // user object + } + ] +} +``` + +## `PATCH /api/pleroma/admin/users/approve` + +### Approve user + +- Params: + - `nicknames`: nicknames array +- Response: + +```json +{ + users: [ + { + // user object + } + ] +} +``` + +## `GET /api/pleroma/admin/users/:nickname_or_id` + +### Retrive the details of a user + +- Params: + - `nickname` or `id` +- Response: + - On failure: `Not found` + - On success: JSON of the user + +## `GET /api/pleroma/admin/users/:nickname_or_id/statuses` + +### Retrive user's latest statuses + +- Params: + - `nickname` or `id` + - *optional* `page_size`: number of statuses to return (default is `20`) + - *optional* `godmode`: `true`/`false` – allows to see private statuses + - *optional* `with_reblogs`: `true`/`false` – allows to see reblogs (default is false) +- Response: + - On failure: `Not found` + - On success: JSON array of user's latest statuses + +## `GET /api/pleroma/admin/instances/:instance/statuses` + +### Retrive instance's latest statuses + +- Params: + - `instance`: instance name + - *optional* `page_size`: number of statuses to return (default is `20`) + - *optional* `godmode`: `true`/`false` – allows to see private statuses + - *optional* `with_reblogs`: `true`/`false` – allows to see reblogs (default is false) +- Response: + - On failure: `Not found` + - On success: JSON array of instance's latest statuses + +## `GET /api/pleroma/admin/statuses` + +### Retrives all latest statuses + +- Params: + - *optional* `page_size`: number of statuses to return (default is `20`) + - *optional* `local_only`: excludes remote statuses + - *optional* `godmode`: `true`/`false` – allows to see private statuses + - *optional* `with_reblogs`: `true`/`false` – allows to see reblogs (default is false) +- Response: + - On failure: `Not found` + - On success: JSON array of user's latest statuses + +## `GET /api/pleroma/admin/relay` + +### List Relays + +Params: none +Response: + +* On success: JSON array of relays + +```json +[ + {"actor": "https://example.com/relay", "followed_back": true}, + {"actor": "https://example2.com/relay", "followed_back": false} +] +``` + +## `POST /api/pleroma/admin/relay` + +### Follow a Relay + +Params: + +* `relay_url` + +Response: + +* On success: relay json object + +```json +{"actor": "https://example.com/relay", "followed_back": true} +``` + +## `DELETE /api/pleroma/admin/relay` + +### Unfollow a Relay + +- Params: + - `relay_url` + - *optional* `force`: forcefully unfollow a relay even when the relay is not available. (default is `false`) + +Response: + +* On success: URL of the unfollowed relay + +```json +{"https://example.com/relay"} +``` + +## `POST /api/pleroma/admin/users/invite_token` + +### Create an account registration invite token + +- Params: + - *optional* `max_use` (integer) + - *optional* `expires_at` (date string e.g. "2019-04-07") +- Response: + +```json +{ + "id": integer, + "token": string, + "used": boolean, + "expires_at": date, + "uses": integer, + "max_use": integer, + "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`) +} +``` + +## `GET /api/pleroma/admin/users/invites` + +### Get a list of generated invites + +- Params: none +- Response: + +```json +{ + + "invites": [ + { + "id": integer, + "token": string, + "used": boolean, + "expires_at": date, + "uses": integer, + "max_use": integer, + "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`) + }, + ... + ] +} +``` + +## `POST /api/pleroma/admin/users/revoke_invite` + +### Revoke invite by token + +- Params: + - `token` +- Response: + +```json +{ + "id": integer, + "token": string, + "used": boolean, + "expires_at": date, + "uses": integer, + "max_use": integer, + "invite_type": string (possible values: `one_time`, `reusable`, `date_limited`, `reusable_date_limited`) + +} +``` + +## `POST /api/pleroma/admin/users/email_invite` + +### Sends registration invite via email + +- Params: + - `email` + - `name`, optional + +- Response: + - On success: `204`, empty response + - On failure: + - 400 Bad Request, JSON: + + ```json + [ + { + "error": "Appropriate error message here" + } + ] + ``` + +## `GET /api/pleroma/admin/users/:nickname/password_reset` + +### Get a password reset token for a given nickname + + +- Params: none +- Response: + +```json +{ + "token": "base64 reset token", + "link": "https://pleroma.social/api/pleroma/password_reset/url-encoded-base64-token" +} +``` + +## `PATCH /api/pleroma/admin/users/force_password_reset` + +### Force passord reset for a user with a given nickname + +- Params: + - `nicknames` +- Response: none (code `204`) + +## PUT `/api/pleroma/admin/users/disable_mfa` + +### Disable mfa for user's account. + +- Params: + - `nickname` +- Response: User’s nickname + +## `GET /api/pleroma/admin/users/:nickname/credentials` + +### Get the user's email, password, display and settings-related fields + +- Params: + - `nickname` + +- Response: + +```json +{ + "actor_type": "Person", + "allow_following_move": true, + "avatar": "https://pleroma.social/media/7e8e7508fd545ef580549b6881d80ec0ff2c81ed9ad37b9bdbbdf0e0d030159d.jpg", + "background": "https://pleroma.social/media/4de34c0bd10970d02cbdef8972bef0ebbf55f43cadc449554d4396156162fe9a.jpg", + "banner": "https://pleroma.social/media/8d92ba2bd244b613520abf557dd448adcd30f5587022813ee9dd068945986946.jpg", + "bio": "bio", + "default_scope": "public", + "discoverable": false, + "email": "user@example.com", + "fields": [ + { + "name": "example", + "value": "https://example.com" + } + ], + "hide_favorites": false, + "hide_followers": false, + "hide_followers_count": false, + "hide_follows": false, + "hide_follows_count": false, + "id": "9oouHaEEUR54hls968", + "locked": true, + "name": "user", + "no_rich_text": true, + "pleroma_settings_store": {}, + "raw_fields": [ + { + "id": 1, + "name": "example", + "value": "https://example.com" + }, + ], + "show_role": true, + "skip_thread_containment": false +} +``` + +## `PATCH /api/pleroma/admin/users/:nickname/credentials` + +### Change the user's email, password, display and settings-related fields + +* Params: + * `email` + * `password` + * `name` + * `bio` + * `avatar` + * `locked` + * `no_rich_text` + * `default_scope` + * `banner` + * `hide_follows` + * `hide_followers` + * `hide_followers_count` + * `hide_follows_count` + * `hide_favorites` + * `allow_following_move` + * `background` + * `show_role` + * `skip_thread_containment` + * `fields` + * `is_discoverable` + * `actor_type` + +* Responses: + +Status: 200 + +```json +{"status": "success"} +``` + +Status: 400 + +```json +{"errors": + {"actor_type": "is invalid"}, + {"email": "has invalid format"}, + ... + } +``` + +Status: 404 + +```json +{"error": "Not found"} +``` + +## `GET /api/pleroma/admin/reports` + +### Get a list of reports + +- Params: + - *optional* `state`: **string** the state of reports. Valid values are `open`, `closed` and `resolved` + - *optional* `limit`: **integer** the number of records to retrieve + - *optional* `page`: **integer** page number + - *optional* `page_size`: **integer** number of log entries per page (default is `50`) +- Response: + - On failure: 403 Forbidden error `{"error": "error_msg"}` when requested by anonymous or non-admin + - On success: JSON, returns a list of reports, where: + - `account`: the user who has been reported + - `actor`: the user who has sent the report + - `statuses`: list of statuses that have been included to the report + +```json +{ + "total" : 1, + "reports": [ + { + "account": { + "acct": "user", + "avatar": "https://pleroma.example.org/images/avi.png", + "avatar_static": "https://pleroma.example.org/images/avi.png", + "bot": false, + "created_at": "2019-04-23T17:32:04.000Z", + "display_name": "User", + "emojis": [], + "fields": [], + "followers_count": 1, + "following_count": 1, + "header": "https://pleroma.example.org/images/banner.png", + "header_static": "https://pleroma.example.org/images/banner.png", + "id": "9i6dAJqSGSKMzLG2Lo", + "locked": false, + "note": "", + "pleroma": { + "confirmation_pending": false, + "hide_favorites": true, + "hide_followers": false, + "hide_follows": false, + "is_admin": false, + "is_moderator": false, + "relationship": {}, + "tags": [] + }, + "source": { + "note": "", + "pleroma": {}, + "sensitive": false + }, + "tags": ["force_unlisted"], + "statuses_count": 3, + "url": "https://pleroma.example.org/users/user", + "username": "user" + }, + "actor": { + "acct": "lain", + "avatar": "https://pleroma.example.org/images/avi.png", + "avatar_static": "https://pleroma.example.org/images/avi.png", + "bot": false, + "created_at": "2019-03-28T17:36:03.000Z", + "display_name": "Roger Braun", + "emojis": [], + "fields": [], + "followers_count": 1, + "following_count": 1, + "header": "https://pleroma.example.org/images/banner.png", + "header_static": "https://pleroma.example.org/images/banner.png", + "id": "9hEkA5JsvAdlSrocam", + "locked": false, + "note": "", + "pleroma": { + "confirmation_pending": false, + "hide_favorites": false, + "hide_followers": false, + "hide_follows": false, + "is_admin": false, + "is_moderator": false, + "relationship": {}, + "tags": [] + }, + "source": { + "note": "", + "pleroma": {}, + "sensitive": false + }, + "tags": ["force_unlisted"], + "statuses_count": 1, + "url": "https://pleroma.example.org/users/lain", + "username": "lain" + }, + "content": "Please delete it", + "created_at": "2019-04-29T19:48:15.000Z", + "id": "9iJGOv1j8hxuw19bcm", + "state": "open", + "statuses": [ + { + "account": { ... }, + "application": { + "name": "Web", + "website": null + }, + "bookmarked": false, + "card": null, + "content": "@lain click on my link https://www.google.com/", + "created_at": "2019-04-23T19:15:47.000Z", + "emojis": [], + "favourited": false, + "favourites_count": 0, + "id": "9i6mQ9uVrrOmOime8m", + "in_reply_to_account_id": null, + "in_reply_to_id": null, + "language": null, + "media_attachments": [], + "mentions": [ + { + "acct": "lain", + "id": "9hEkA5JsvAdlSrocam", + "url": "https://pleroma.example.org/users/lain", + "username": "lain" + }, + { + "acct": "user", + "id": "9i6dAJqSGSKMzLG2Lo", + "url": "https://pleroma.example.org/users/user", + "username": "user" + } + ], + "muted": false, + "pinned": false, + "pleroma": { + "content": { + "text/plain": "@lain click on my link https://www.google.com/" + }, + "conversation_id": 28, + "in_reply_to_account_acct": null, + "local": true, + "spoiler_text": { + "text/plain": "" + } + }, + "reblog": null, + "reblogged": false, + "reblogs_count": 0, + "replies_count": 0, + "sensitive": false, + "spoiler_text": "", + "tags": [], + "uri": "https://pleroma.example.org/objects/8717b90f-8e09-4b58-97b0-e3305472b396", + "url": "https://pleroma.example.org/notice/9i6mQ9uVrrOmOime8m", + "visibility": "direct" + } + ] + } + ] +} +``` + +## `GET /api/pleroma/admin/grouped_reports` + +### Get a list of reports, grouped by status + +- Params: none +- On success: JSON, returns a list of reports, where: + - `date`: date of the latest report + - `account`: the user who has been reported (see `/api/pleroma/admin/reports` for reference) + - `status`: reported status (see `/api/pleroma/admin/reports` for reference) + - `actors`: users who had reported this status (see `/api/pleroma/admin/reports` for reference) + - `reports`: reports (see `/api/pleroma/admin/reports` for reference) + +```json + "reports": [ + { + "date": "2019-10-07T12:31:39.615149Z", + "account": { ... }, + "status": { ... }, + "actors": [{ ... }, { ... }], + "reports": [{ ... }] + } + ] +``` + +## `GET /api/pleroma/admin/reports/:id` + +### Get an individual report + +- Params: + - `id` +- Response: + - On failure: + - 403 Forbidden `{"error": "error_msg"}` + - 404 Not Found `"Not found"` + - On success: JSON, Report object (see above) + +## `PATCH /api/pleroma/admin/reports` + +### Change the state of one or multiple reports + +- Params: + +```json + `reports`: [ + { + `id`, // required, report id + `state` // required, the new state. Valid values are `open`, `closed` and `resolved` + }, + ... + ] +``` + +- Response: + - On failure: + - 400 Bad Request, JSON: + + ```json + [ + { + `id`, // report id + `error` // error message + } + ] + ``` + + - On success: `204`, empty response + +## `POST /api/pleroma/admin/reports/:id/notes` + +### Create report note + +- Params: + - `id`: required, report id + - `content`: required, the message +- Response: + - On failure: + - 400 Bad Request `"Invalid parameters"` when `status` is missing + - On success: `204`, empty response + +## `DELETE /api/pleroma/admin/reports/:report_id/notes/:id` + +### Delete report note + +- Params: + - `report_id`: required, report id + - `id`: required, note id +- Response: + - On failure: + - 400 Bad Request `"Invalid parameters"` when `status` is missing + - On success: `204`, empty response + +## `GET /api/pleroma/admin/statuses/:id` + +### Show status by id + +- Params: + - `id`: required, status id +- Response: + - On failure: + - 404 Not Found `"Not Found"` + - On success: JSON, Mastodon Status entity + +## `PUT /api/pleroma/admin/statuses/:id` + +### Change the scope of an individual reported status + +- Params: + - `id` + - `sensitive`: optional, valid values are `true` or `false` + - `visibility`: optional, valid values are `public`, `private` and `unlisted` +- Response: + - On failure: + - 400 Bad Request `"Unsupported visibility"` + - 403 Forbidden `{"error": "error_msg"}` + - 404 Not Found `"Not found"` + - On success: JSON, Mastodon Status entity + +## `DELETE /api/pleroma/admin/statuses/:id` + +### Delete an individual reported status + +- Params: + - `id` +- Response: + - On failure: + - 403 Forbidden `{"error": "error_msg"}` + - 404 Not Found `"Not found"` + - On success: 200 OK `{}` + +## `GET /api/pleroma/admin/restart` + +### Restarts pleroma application + +**Only works when configuration from database is enabled.** + +- Params: none +- Response: + - On failure: + - 400 Bad Request `"To use this endpoint you need to enable configuration from database."` + +```json +{} +``` + +## `GET /api/pleroma/admin/need_reboot` + +### Returns the flag whether the pleroma should be restarted + +- Params: none +- Response: + - `need_reboot` - boolean +```json +{ + "need_reboot": false +} +``` + +## `GET /api/pleroma/admin/config` + +### Get list of merged default settings with saved in database. + +*If `need_reboot` is `true`, instance must be restarted, so reboot time settings can take effect.* + +**Only works when configuration from database is enabled.** + +- Params: + - `only_db`: true (*optional*, get only saved in database settings) +- Response: + - On failure: + - 400 Bad Request `"To use this endpoint you need to enable configuration from database."` + +```json +{ + "configs": [ + { + "group": ":pleroma", + "key": "Pleroma.Upload", + "value": [] + } + ], + "need_reboot": true +} +``` + +## `POST /api/pleroma/admin/config` + +### Update config settings + +*If `need_reboot` is `true`, instance must be restarted, so reboot time settings can take effect.* + +**Only works when configuration from database is enabled.** + +Some modifications are necessary to save the config settings correctly: + +- strings which start with `Pleroma.`, `Phoenix.`, `Tesla.` or strings like `Oban`, `Ueberauth` will be converted to modules; +``` +"Pleroma.Upload" -> Pleroma.Upload +"Oban" -> Oban +``` +- strings starting with `:` will be converted to atoms; +``` +":pleroma" -> :pleroma +``` +- objects with `tuple` key and array value will be converted to tuples; +``` +{"tuple": ["string", "Pleroma.Upload", []]} -> {"string", Pleroma.Upload, []} +``` +- arrays with *tuple objects* will be converted to keywords; +``` +[{"tuple": [":key1", "value"]}, {"tuple": [":key2", "value"]}] -> [key1: "value", key2: "value"] +``` + +Most of the settings will be applied in `runtime`, this means that you don't need to restart the instance. But some settings are applied in `compile time` and require a reboot of the instance, such as: +- all settings inside these keys: + - `:hackney_pools` + - `:connections_pool` + - `:pools` + - `:chat` +- partially settings inside these keys: + - `:seconds_valid` in `Pleroma.Captcha` + - `:proxy_remote` in `Pleroma.Upload` + - `:upload_limit` in `:instance` + +- Params: + - `configs` - array of config objects + - config object params: + - `group` - string (**required**) + - `key` - string (**required**) + - `value` - string, [], {} or {"tuple": []} (**required**) + - `delete` - true (*optional*, if setting must be deleted) + - `subkeys` - array of strings (*optional*, only works when `delete=true` parameter is passed, otherwise will be ignored) + +*When a value have several nested settings, you can delete only some nested settings by passing a parameter `subkeys`, without deleting all settings by key.* +``` +[subkey: val1, subkey2: val2, subkey3: val3] \\ initial value +{"group": ":pleroma", "key": "some_key", "delete": true, "subkeys": [":subkey", ":subkey3"]} \\ passing json for deletion +[subkey2: val2] \\ value after deletion +``` + +*Most of the settings can be partially updated through merge old values with new values, except settings value of which is list or is not keyword.* + +Example of setting without keyword in value: +```elixir +config :tesla, :adapter, Tesla.Adapter.Hackney +``` + +List of settings which support only full update by key: +```elixir +@full_key_update [ + {:pleroma, :ecto_repos}, + {:quack, :meta}, + {:mime, :types}, + {:cors_plug, [:max_age, :methods, :expose, :headers]}, + {:auto_linker, :opts}, + {:swarm, :node_blacklist}, + {:logger, :backends} + ] +``` + +List of settings which support only full update by subkey: +```elixir +@full_subkey_update [ + {:pleroma, :assets, :mascots}, + {:pleroma, :emoji, :groups}, + {:pleroma, :workers, :retries}, + {:pleroma, :mrf_subchain, :match_actor}, + {:pleroma, :mrf_keyword, :replace} + ] +``` + +*Settings without explicit key must be sended in separate config object params.* +```elixir +config :quack, + level: :debug, + meta: [:all], + ... +``` +```json +{ + "configs": [ + {"group": ":quack", "key": ":level", "value": ":debug"}, + {"group": ":quack", "key": ":meta", "value": [":all"]}, + ... + ] +} +``` +- Request: + +```json +{ + "configs": [ + { + "group": ":pleroma", + "key": "Pleroma.Upload", + "value": [ + {"tuple": [":uploader", "Pleroma.Uploaders.Local"]}, + {"tuple": [":filters", ["Pleroma.Upload.Filter.Dedupe"]]}, + {"tuple": [":link_name", true]}, + {"tuple": [":proxy_remote", false]}, + {"tuple": [":proxy_opts", [ + {"tuple": [":redirect_on_failure", false]}, + {"tuple": [":max_body_length", 1048576]}, + {"tuple": [":http", [ + {"tuple": [":follow_redirect", true]}, + {"tuple": [":pool", ":upload"]}, + ]]} + ] + ]}, + {"tuple": [":dispatch", { + "tuple": ["/api/v1/streaming", "Pleroma.Web.MastodonAPI.WebsocketHandler", []] + }]} + ] + } + ] +} +``` + +- Response: + - On failure: + - 400 Bad Request `"To use this endpoint you need to enable configuration from database."` +```json +{ + "configs": [ + { + "group": ":pleroma", + "key": "Pleroma.Upload", + "value": [...] + } + ], + "need_reboot": true +} +``` + +## ` GET /api/pleroma/admin/config/descriptions` + +### Get JSON with config descriptions. +Loads json generated from `config/descriptions.exs`. + +- Params: none +- Response: + +```json +[{ + "group": ":pleroma", // string + "key": "ModuleName", // string + "type": "group", // string or list with possible values, + "description": "Upload general settings", // string + "children": [ + { + "key": ":uploader", // string or module name `Pleroma.Upload` + "type": "module", + "description": "Module which will be used for uploads", + "suggestions": ["module1", "module2"] + }, + { + "key": ":filters", + "type": ["list", "module"], + "description": "List of filter modules for uploads", + "suggestions": [ + "module1", "module2", "module3" + ] + } + ] +}] +``` + +## `GET /api/pleroma/admin/moderation_log` + +### Get moderation log + +- Params: + - *optional* `page`: **integer** page number + - *optional* `page_size`: **integer** number of log entries per page (default is `50`) + - *optional* `start_date`: **datetime (ISO 8601)** filter logs by creation date, start from `start_date`. Accepts datetime in ISO 8601 format (YYYY-MM-DDThh:mm:ss), e.g. `2005-08-09T18:31:42` + - *optional* `end_date`: **datetime (ISO 8601)** filter logs by creation date, end by from `end_date`. Accepts datetime in ISO 8601 format (YYYY-MM-DDThh:mm:ss), e.g. 2005-08-09T18:31:42 + - *optional* `user_id`: **integer** filter logs by actor's id + - *optional* `search`: **string** search logs by the log message +- Response: + +```json +[ + { + "id": 1234, + "data": { + "actor": { + "id": 1, + "nickname": "lain" + }, + "action": "relay_follow" + }, + "time": 1502812026, // timestamp + "message": "[2017-08-15 15:47:06] @nick0 followed relay: https://example.org/relay" // log message + } +] +``` + +## `POST /api/pleroma/admin/reload_emoji` + +### Reload the instance's custom emoji + +- Authentication: required +- Params: None +- Response: JSON, "ok" and 200 status + +## `PATCH /api/pleroma/admin/users/confirm_email` + +### Confirm users' emails + +- Params: + - `nicknames` +- Response: Array of user nicknames + +## `PATCH /api/pleroma/admin/users/resend_confirmation_email` + +### Resend confirmation email + +- Params: + - `nicknames` +- Response: Array of user nicknames + +## `GET /api/pleroma/admin/stats` + +### Stats + +- Query Params: + - *optional* `instance`: **string** instance hostname (without protocol) to get stats for +- Example: `https://mypleroma.org/api/pleroma/admin/stats?instance=lain.com` + +- Response: + +```json +{ + "status_visibility": { + "direct": 739, + "private": 9, + "public": 17, + "unlisted": 14 + } +} +``` + +## `GET /api/pleroma/admin/oauth_app` + +### List OAuth app + +- Params: + - *optional* `name` + - *optional* `client_id` + - *optional* `page` + - *optional* `page_size` + - *optional* `trusted` + +- Response: + +```json +{ + "apps": [ + { + "id": 1, + "name": "App name", + "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk", + "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY", + "redirect_uri": "https://example.com/oauth-callback", + "website": "https://example.com", + "trusted": true + } + ], + "count": 17, + "page_size": 50 +} +``` + + +## `POST /api/pleroma/admin/oauth_app` + +### Create OAuth App + +- Params: + - `name` + - `redirect_uris` + - `scopes` + - *optional* `website` + - *optional* `trusted` + +- Response: + +```json +{ + "id": 1, + "name": "App name", + "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk", + "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY", + "redirect_uri": "https://example.com/oauth-callback", + "website": "https://example.com", + "trusted": true +} +``` + +- On failure: +```json +{ + "redirect_uris": "can't be blank", + "name": "can't be blank" +} +``` + +## `PATCH /api/pleroma/admin/oauth_app/:id` + +### Update OAuth App + +- Params: + - *optional* `name` + - *optional* `redirect_uris` + - *optional* `scopes` + - *optional* `website` + - *optional* `trusted` + +- Response: + +```json +{ + "id": 1, + "name": "App name", + "client_id": "yHoDSiWYp5mPV6AfsaVOWjdOyt5PhWRiafi6MRd1lSk", + "client_secret": "nLmis486Vqrv2o65eM9mLQx_m_4gH-Q6PcDpGIMl6FY", + "redirect_uri": "https://example.com/oauth-callback", + "website": "https://example.com", + "trusted": true +} +``` + +## `DELETE /api/pleroma/admin/oauth_app/:id` + +### Delete OAuth App + +- Params: None + +- Response: + - On success: `204`, empty response + - On failure: + - 400 Bad Request `"Invalid parameters"` when `status` is missing + +## `GET /api/pleroma/admin/media_proxy_caches` + +### Get a list of all banned MediaProxy URLs in Cachex + +- Authentication: required +- Params: +- *optional* `page`: **integer** page number +- *optional* `page_size`: **integer** number of log entries per page (default is `50`) +- *optional* `query`: **string** search term + +- Response: + +``` json +{ + "page_size": integer, + "count": integer, + "urls": [ + "http://example.com/media/a688346.jpg", + "http://example.com/media/fb1f4d.jpg" + ] +} + +``` + +## `POST /api/pleroma/admin/media_proxy_caches/delete` + +### Remove a banned MediaProxy URL from Cachex + +- Authentication: required +- Params: + - `urls` (array) + +- Response: + +``` json +{ } + +``` + +## `POST /api/pleroma/admin/media_proxy_caches/purge` + +### Purge a MediaProxy URL + +- Authentication: required +- Params: + - `urls` (array) + - `ban` (boolean) + +- Response: + +``` json +{ } + +``` + +## GET /api/pleroma/admin/users/:nickname/chats + +### List a user's chats + +- Params: None + +- Response: + +```json +[ + { + "sender": { + "id": "someflakeid", + "username": "somenick", + ... + }, + "receiver": { + "id": "someflakeid", + "username": "somenick", + ... + }, + "id" : "1", + "unread" : 2, + "last_message" : {...}, // The last message in that chat + "updated_at": "2020-04-21T15:11:46.000Z" + } +] +``` + +## GET /api/pleroma/admin/chats/:chat_id + +### View a single chat + +- Params: None + +- Response: + +```json +{ + "sender": { + "id": "someflakeid", + "username": "somenick", + ... + }, + "receiver": { + "id": "someflakeid", + "username": "somenick", + ... + }, + "id" : "1", + "unread" : 2, + "last_message" : {...}, // The last message in that chat + "updated_at": "2020-04-21T15:11:46.000Z" +} +``` + +## GET /api/pleroma/admin/chats/:chat_id/messages + +### List the messages in a chat + +- Params: `max_id`, `min_id` + +- Response: + +```json +[ + { + "account_id": "someflakeid", + "chat_id": "1", + "content": "Check this out :firefox:", + "created_at": "2020-04-21T15:11:46.000Z", + "emojis": [ + { + "shortcode": "firefox", + "static_url": "https://dontbulling.me/emoji/Firefox.gif", + "url": "https://dontbulling.me/emoji/Firefox.gif", + "visible_in_picker": false + } + ], + "id": "13", + "unread": true + }, + { + "account_id": "someflakeid", + "chat_id": "1", + "content": "Whats' up?", + "created_at": "2020-04-21T15:06:45.000Z", + "emojis": [], + "id": "12", + "unread": false + } +] +``` + +## DELETE /api/pleroma/admin/chats/:chat_id/messages/:message_id + +### Delete a single message + +- Params: None + +- Response: + +```json +{ + "account_id": "someflakeid", + "chat_id": "1", + "content": "Check this out :firefox:", + "created_at": "2020-04-21T15:11:46.000Z", + "emojis": [ + { + "shortcode": "firefox", + "static_url": "https://dontbulling.me/emoji/Firefox.gif", + "url": "https://dontbulling.me/emoji/Firefox.gif", + "visible_in_picker": false + } + ], + "id": "13", + "unread": false +} +``` + +## `GET /api/pleroma/admin/instance_document/:document_name` + +### Get an instance document + +- Authentication: required + +- Response: + +Returns the content of the document + +```html +

Instance panel

+``` + +## `PATCH /api/pleroma/admin/instance_document/:document_name` +- Params: + - `file` (the file to be uploaded, using multipart form data.) + +### Update an instance document + +- Authentication: required + +- Response: + +``` json +{ + "url": "https://example.com/instance/panel.html" +} +``` + +## `DELETE /api/pleroma/admin/instance_document/:document_name` + +### Delete an instance document + +- Response: + +``` json +{ + "url": "https://example.com/instance/panel.html" +} +``` + +## `GET /api/pleroma/admin/frontends + +### List available frontends + +- Response: + +```json +[ + { + "build_url": "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build", + "git": "https://git.pleroma.social/pleroma/fedi-fe", + "installed": true, + "name": "fedi-fe", + "ref": "master" + }, + { + "build_url": "https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build", + "git": "https://git.pleroma.social/lambadalambda/kenoma", + "installed": false, + "name": "kenoma", + "ref": "master" + } +] +``` + +## `POST /api/pleroma/admin/frontends/install` + +### Install a frontend + +- Params: + - `name`: frontend name, required + - `ref`: frontend ref + - `file`: path to a frontend zip file + - `build_url`: build URL + - `build_dir`: build directory + +- Response: + +```json +[ + { + "build_url": "https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build", + "git": "https://git.pleroma.social/pleroma/fedi-fe", + "installed": true, + "name": "fedi-fe", + "ref": "master" + }, + { + "build_url": "https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build", + "git": "https://git.pleroma.social/lambadalambda/kenoma", + "installed": false, + "name": "kenoma", + "ref": "master" + } +] +``` + +```json +{ + "error": "Could not install frontend" +} +``` diff --git a/docs/development/API/chats.md b/docs/development/API/chats.md new file mode 100644 index 000000000..f50144c86 --- /dev/null +++ b/docs/development/API/chats.md @@ -0,0 +1,255 @@ +# Chats + +Chats are a way to represent an IM-style conversation between two actors. They are not the same as direct messages and they are not `Status`es, even though they have a lot in common. + +## Why Chats? + +There are no 'visibility levels' in ActivityPub, their definition is purely a Mastodon convention. Direct Messaging between users on the fediverse has mostly been modeled by using ActivityPub addressing following Mastodon conventions on normal `Note` objects. In this case, a 'direct message' would be a message that has no followers addressed and also does not address the special public actor, but just the recipients in the `to` field. It would still be a `Note` and is presented with other `Note`s as a `Status` in the API. + +This is an awkward setup for a few reasons: + +- As DMs generally still follow the usual `Status` conventions, it is easy to accidentally pull somebody into a DM thread by mentioning them. (e.g. "I hate @badguy so much") +- It is possible to go from a publicly addressed `Status` to a DM reply, back to public, then to a 'followers only' reply, and so on. This can be become very confusing, as it is unclear which user can see which part of the conversation. +- The standard `Status` format of implicit addressing also leads to rather ugly results if you try to display the messages as a chat, because all the recipients are always mentioned by name in the message. +- As direct messages are posted with the same api call (and usually same frontend component) as public messages, accidentally making a public message private or vice versa can happen easily. Client bugs can also lead to this, accidentally making private messages public. + +As a measure to improve this situation, the `Conversation` concept and related Pleroma extensions were introduced. While it made it possible to work around a few of the issues, many of the problems remained and it didn't see much adoption because it was too complicated to use correctly. + +## Chats explained +For this reasons, Chats are a new and different entity, both in the API as well as in ActivityPub. A quick overview: + +- Chats are meant to represent an instant message conversation between two actors. For now these are only 1-on-1 conversations, but the other actor can be a group in the future. +- Chat messages have the ActivityPub type `ChatMessage`. They are not `Note`s. Servers that don't understand them will just drop them. +- The only addressing allowed in `ChatMessage`s is one single ActivityPub actor in the `to` field. +- There's always only one Chat between two actors. If you start chatting with someone and later start a 'new' Chat, the old Chat will be continued. +- `ChatMessage`s are posted with a different api, making it very hard to accidentally send a message to the wrong person. +- `ChatMessage`s don't show up in the existing timelines. +- Chats can never go from private to public. They are always private between the two actors. + +## Caveats + +- Chats are NOT E2E encrypted (yet). Security is still the same as email. + +## API + +In general, the way to send a `ChatMessage` is to first create a `Chat`, then post a message to that `Chat`. `Group`s will later be supported by making them a sub-type of `Account`. + +This is the overview of using the API. The API is also documented via OpenAPI, so you can view it and play with it by pointing SwaggerUI or a similar OpenAPI tool to `https://yourinstance.tld/api/openapi`. + +### Creating or getting a chat. + +To create or get an existing Chat for a certain recipient (identified by Account ID) +you can call: + +`POST /api/v1/pleroma/chats/by-account-id/:account_id` + +The account id is the normal FlakeId of the user +``` +POST /api/v1/pleroma/chats/by-account-id/someflakeid +``` + +If you already have the id of a chat, you can also use + +``` +GET /api/v1/pleroma/chats/:id +``` + +There will only ever be ONE Chat for you and a given recipient, so this call +will return the same Chat if you already have one with that user. + +Returned data: + +```json +{ + "account": { + "id": "someflakeid", + "username": "somenick", + ... + }, + "id" : "1", + "unread" : 2, + "last_message" : {...}, // The last message in that chat + "updated_at": "2020-04-21T15:11:46.000Z" +} +``` + +### Marking a chat as read + +To mark a number of messages in a chat up to a certain message as read, you can use + +`POST /api/v1/pleroma/chats/:id/read` + + +Parameters: +- last_read_id: Given this id, all chat messages until this one will be marked as read. Required. + + +Returned data: + +```json +{ + "account": { + "id": "someflakeid", + "username": "somenick", + ... + }, + "id" : "1", + "unread" : 0, + "updated_at": "2020-04-21T15:11:46.000Z" +} +``` + +### Marking a single chat message as read + +To set the `unread` property of a message to `false` + +`POST /api/v1/pleroma/chats/:id/messages/:message_id/read` + +Returned data: + +The modified chat message + +### Getting a list of Chats + +`GET /api/v1/pleroma/chats` + +This will return a list of chats that you have been involved in, sorted by their +last update (so new chats will be at the top). + +Parameters: + +- with_muted: Include chats from muted users (boolean). + +Returned data: + +```json +[ + { + "account": { + "id": "someflakeid", + "username": "somenick", + ... + }, + "id" : "1", + "unread" : 2, + "last_message" : {...}, // The last message in that chat + "updated_at": "2020-04-21T15:11:46.000Z" + } +] +``` + +The recipient of messages that are sent to this chat is given by their AP ID. +No pagination is implemented for now. + +### Getting the messages for a Chat + +For a given Chat id, you can get the associated messages with + +`GET /api/v1/pleroma/chats/:id/messages` + +This will return all messages, sorted by most recent to least recent. The usual +pagination options are implemented. + +Returned data: + +```json +[ + { + "account_id": "someflakeid", + "chat_id": "1", + "content": "Check this out :firefox:", + "created_at": "2020-04-21T15:11:46.000Z", + "emojis": [ + { + "shortcode": "firefox", + "static_url": "https://dontbulling.me/emoji/Firefox.gif", + "url": "https://dontbulling.me/emoji/Firefox.gif", + "visible_in_picker": false + } + ], + "id": "13", + "unread": true + }, + { + "account_id": "someflakeid", + "chat_id": "1", + "content": "Whats' up?", + "created_at": "2020-04-21T15:06:45.000Z", + "emojis": [], + "id": "12", + "unread": false, + "idempotency_key": "75442486-0874-440c-9db1-a7006c25a31f" + } +] +``` + +- idempotency_key: The copy of the `idempotency-key` HTTP request header that can be used for optimistic message sending. Included only during the first few minutes after the message creation. + +### Posting a chat message + +Posting a chat message for given Chat id works like this: + +`POST /api/v1/pleroma/chats/:id/messages` + +Parameters: +- content: The text content of the message. Optional if media is attached. +- media_id: The id of an upload that will be attached to the message. + +Currently, no formatting beyond basic escaping and emoji is implemented. + +Returned data: + +```json +{ + "account_id": "someflakeid", + "chat_id": "1", + "content": "Check this out :firefox:", + "created_at": "2020-04-21T15:11:46.000Z", + "emojis": [ + { + "shortcode": "firefox", + "static_url": "https://dontbulling.me/emoji/Firefox.gif", + "url": "https://dontbulling.me/emoji/Firefox.gif", + "visible_in_picker": false + } + ], + "id": "13", + "unread": false +} +``` + +### Deleting a chat message + +Deleting a chat message for given Chat id works like this: + +`DELETE /api/v1/pleroma/chats/:chat_id/messages/:message_id` + +Returned data is the deleted message. + +### Notifications + +There's a new `pleroma:chat_mention` notification, which has this form. It is not given out in the notifications endpoint by default, you need to explicitly request it with `include_types[]=pleroma:chat_mention`: + +```json +{ + "id": "someid", + "type": "pleroma:chat_mention", + "account": { ... } // User account of the sender, + "chat_message": { + "chat_id": "1", + "id": "10", + "content": "Hello", + "account_id": "someflakeid", + "unread": false + }, + "created_at": "somedate" +} +``` + +### Streaming + +There is an additional `user:pleroma_chat` stream. Incoming chat messages will make the current chat be sent to this `user` stream. The `event` of an incoming chat message is `pleroma:chat_update`. The payload is the updated chat with the incoming chat message in the `last_message` field. + +### Web Push + +If you want to receive push messages for this type, you'll need to add the `pleroma:chat_mention` type to your alerts in the push subscription. diff --git a/docs/development/API/differences_in_mastoapi_responses.md b/docs/development/API/differences_in_mastoapi_responses.md new file mode 100644 index 000000000..84430408b --- /dev/null +++ b/docs/development/API/differences_in_mastoapi_responses.md @@ -0,0 +1,346 @@ +# Differences in Mastodon API responses from vanilla Mastodon + +A Pleroma instance can be identified by " (compatible; Pleroma )" present in `version` field in response from `/api/v1/instance` + +## Flake IDs + +Pleroma uses 128-bit ids as opposed to Mastodon's 64 bits. However, just like Mastodon's ids, they are lexically sortable strings + +## Timelines + +Adding the parameter `with_muted=true` to the timeline queries will also return activities by muted (not by blocked!) users. + +Adding the parameter `exclude_visibilities` to the timeline queries will exclude the statuses with the given visibilities. The parameter accepts an array of visibility types (`public`, `unlisted`, `private`, `direct`), e.g., `exclude_visibilities[]=direct&exclude_visibilities[]=private`. + +Adding the parameter `reply_visibility` to the public and home timelines queries will filter replies. Possible values: without parameter (default) shows all replies, `following` - replies directed to you or users you follow, `self` - replies directed to you. + +Adding the parameter `instance=lain.com` to the public timeline will show only statuses originating from `lain.com` (or any remote instance). + +## Statuses + +- `visibility`: has additional possible values `list` and `local` (for local-only statuses) + +Has these additional fields under the `pleroma` object: + +- `local`: true if the post was made on the local instance +- `conversation_id`: the ID of the AP context the status is associated with (if any) +- `direct_conversation_id`: the ID of the Mastodon direct message conversation the status is associated with (if any) +- `in_reply_to_account_acct`: the `acct` property of User entity for replied user (if any) +- `content`: a map consisting of alternate representations of the `content` property with the key being its mimetype. Currently, the only alternate representation supported is `text/plain` +- `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being its mimetype. Currently, the only alternate representation supported is `text/plain` +- `expires_at`: a datetime (iso8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire +- `thread_muted`: true if the thread the post belongs to is muted +- `emoji_reactions`: A list with emoji / reaction maps. The format is `{name: "☕", count: 1, me: true}`. Contains no information about the reacting users, for that use the `/statuses/:id/reactions` endpoint. +- `parent_visible`: If the parent of this post is visible to the user or not. + +## Media Attachments + +Has these additional fields under the `pleroma` object: + +- `mime_type`: mime type of the attachment. + +### Attachment cap + +Some apps operate under the assumption that no more than 4 attachments can be returned or uploaded. Pleroma however does not enforce any limits on attachment count neither when returning the status object nor when posting. + +### Limitations + +Pleroma does not process remote images and therefore cannot include fields such as `meta` and `blurhash`. It does not support focal points or aspect ratios. The frontend is expected to handle it. + +## Accounts + +The `id` parameter can also be the `nickname` of the user. This only works in these endpoints, not the deeper nested ones for following etc. + +- `/api/v1/accounts/:id` +- `/api/v1/accounts/:id/statuses` + +Has these additional fields under the `pleroma` object: + +- `ap_id`: nullable URL string, ActivityPub id of the user +- `background_image`: nullable URL string, background image of the user +- `tags`: Lists an array of tags for the user +- `relationship` (object): Includes fields as documented for Mastodon API https://docs.joinmastodon.org/entities/relationship/ +- `is_moderator`: boolean, nullable, true if user is a moderator +- `is_admin`: boolean, nullable, true if user is an admin +- `confirmation_pending`: boolean, true if a new user account is waiting on email confirmation to be activated +- `hide_favorites`: boolean, true when the user has hiding favorites enabled +- `hide_followers`: boolean, true when the user has follower hiding enabled +- `hide_follows`: boolean, true when the user has follow hiding enabled +- `hide_followers_count`: boolean, true when the user has follower stat hiding enabled +- `hide_follows_count`: boolean, true when the user has follow stat hiding enabled +- `settings_store`: A generic map of settings for frontends. Opaque to the backend. Only returned in `/api/v1/accounts/verify_credentials` and `/api/v1/accounts/update_credentials` +- `chat_token`: The token needed for Pleroma chat. Only returned in `/api/v1/accounts/verify_credentials` +- `deactivated`: boolean, true when the user is deactivated +- `allow_following_move`: boolean, true when the user allows automatically follow moved following accounts +- `unread_conversation_count`: The count of unread conversations. Only returned to the account owner. +- `unread_notifications_count`: The count of unread notifications. Only returned to the account owner. +- `notification_settings`: object, can be absent. See `/api/pleroma/notification_settings` for the parameters/keys returned. +- `accepts_chat_messages`: boolean, but can be null if we don't have that information about a user +- `favicon`: nullable URL string, Favicon image of the user's instance + +### Source + +Has these additional fields under the `pleroma` object: + +- `show_role`: boolean, nullable, true when the user wants his role (e.g admin, moderator) to be shown +- `no_rich_text` - boolean, nullable, true when html tags are stripped from all statuses requested from the API +- `discoverable`: boolean, true when the user allows external services (search bots) etc. to index / list the account (regardless of this setting, user will still appear in regular search results) +- `actor_type`: string, the type of this account. + +## Conversations + +Has an additional field under the `pleroma` object: + +- `recipients`: The list of the recipients of this Conversation. These will be addressed when replying to this conversation. + +## GET `/api/v1/conversations` + +Accepts additional parameters: + +- `recipients`: Only return conversations with the given recipients (a list of user ids). Usage example: `GET /api/v1/conversations?recipients[]=1&recipients[]=2` + +## Account Search + +Behavior has changed: + +- `/api/v1/accounts/search`: Does not require authentication + +## Search (global) + +Unlisted posts are available in search results, they are considered to be public posts that shouldn't be shown in local/federated timeline. + +## Notifications + +Has these additional fields under the `pleroma` object: + +- `is_seen`: true if the notification was read by the user + +### Move Notification + +The `type` value is `move`. Has an additional field: + +- `target`: new account + +### EmojiReact Notification + +The `type` value is `pleroma:emoji_reaction`. Has these fields: + +- `emoji`: The used emoji +- `account`: The account of the user who reacted +- `status`: The status that was reacted on + +### ChatMention Notification (not default) + +This notification has to be requested explicitly. + +The `type` value is `pleroma:chat_mention` + +- `account`: The account who sent the message +- `chat_message`: The chat message + +### Report Notification (not default) + +This notification has to be requested explicitly. + +The `type` value is `pleroma:report` + +- `account`: The account who reported +- `report`: The report + +## GET `/api/v1/notifications` + +Accepts additional parameters: + +- `exclude_visibilities`: will exclude the notifications for activities with the given visibilities. The parameter accepts an array of visibility types (`public`, `unlisted`, `private`, `direct`). Usage example: `GET /api/v1/notifications?exclude_visibilities[]=direct&exclude_visibilities[]=private`. +- `include_types`: will include the notifications for activities with the given types. The parameter accepts an array of types (`mention`, `follow`, `reblog`, `favourite`, `move`, `pleroma:emoji_reaction`, `pleroma:chat_mention`, `pleroma:report`). Usage example: `GET /api/v1/notifications?include_types[]=mention&include_types[]=reblog`. + +## DELETE `/api/v1/notifications/destroy_multiple` + +An endpoint to delete multiple statuses by IDs. + +Required parameters: + +- `ids`: array of activity ids + +Usage example: `DELETE /api/v1/notifications/destroy_multiple/?ids[]=1&ids[]=2`. + +Returns on success: 200 OK `{}` + +## POST `/api/v1/statuses` + +Additional parameters can be added to the JSON body/Form data: + +- `preview`: boolean, if set to `true` the post won't be actually posted, but the status entity would still be rendered back. This could be useful for previewing rich text/custom emoji, for example. +- `content_type`: string, contain the MIME type of the status, it is transformed into HTML by the backend. You can get the list of the supported MIME types with the nodeinfo endpoint. +- `to`: A list of nicknames (like `lain@soykaf.club` or `lain` on the local server) that will be used to determine who is going to be addressed by this post. Using this will disable the implicit addressing by mentioned names in the `status` body, only the people in the `to` list will be addressed. The normal rules for post visibility are not affected by this and will still apply. +- `visibility`: string, besides standard MastoAPI values (`direct`, `private`, `unlisted`, `local` or `public`) it can be used to address a List by setting it to `list:LIST_ID`. +- `expires_in`: The number of seconds the posted activity should expire in. When a posted activity expires it will be deleted from the server, and a delete request for it will be federated. This needs to be longer than an hour. +- `in_reply_to_conversation_id`: Will reply to a given conversation, addressing only the people who are part of the recipient set of that conversation. Sets the visibility to `direct`. + +## GET `/api/v1/statuses` + +An endpoint to get multiple statuses by IDs. + +Required parameters: + +- `ids`: array of activity ids + +Usage example: `GET /api/v1/statuses/?ids[]=1&ids[]=2`. + +Returns: array of Status. + +The maximum number of statuses is limited to 100 per request. + +## PATCH `/api/v1/accounts/update_credentials` + +Additional parameters can be added to the JSON body/Form data: + +- `no_rich_text` - if true, html tags are stripped from all statuses requested from the API +- `hide_followers` - if true, user's followers will be hidden +- `hide_follows` - if true, user's follows will be hidden +- `hide_followers_count` - if true, user's follower count will be hidden +- `hide_follows_count` - if true, user's follow count will be hidden +- `hide_favorites` - if true, user's favorites timeline will be hidden +- `show_role` - if true, user's role (e.g admin, moderator) will be exposed to anyone in the API +- `default_scope` - the scope returned under `privacy` key in Source subentity +- `pleroma_settings_store` - Opaque user settings to be saved on the backend. +- `skip_thread_containment` - if true, skip filtering out broken threads +- `allow_following_move` - if true, allows automatically follow moved following accounts +- `also_known_as` - array of ActivityPub IDs, needed for following move +- `pleroma_background_image` - sets the background image of the user. Can be set to "" (an empty string) to reset. +- `discoverable` - if true, external services (search bots) etc. are allowed to index / list the account (regardless of this setting, user will still appear in regular search results). +- `actor_type` - the type of this account. +- `accepts_chat_messages` - if false, this account will reject all chat messages. + +All images (avatar, banner and background) can be reset to the default by sending an empty string ("") instead of a file. + +### Pleroma Settings Store + +Pleroma has mechanism that allows frontends to save blobs of json for each user on the backend. This can be used to save frontend-specific settings for a user that the backend does not need to know about. + +The parameter should have a form of `{frontend_name: {...}}`, with `frontend_name` identifying your type of client, e.g. `pleroma_fe`. It will overwrite everything under this property, but will not overwrite other frontend's settings. + +This information is returned in the `/api/v1/accounts/verify_credentials` endpoint. + +## Authentication + +*Pleroma supports refreshing tokens.* + +`POST /oauth/token` + +Post here request with `grant_type=refresh_token` to obtain new access token. Returns an access token. + +## Account Registration + +`POST /api/v1/accounts` + +Has these additional parameters (which are the same as in Pleroma-API): + +- `fullname`: optional +- `bio`: optional +- `captcha_solution`: optional, contains provider-specific captcha solution, +- `captcha_token`: optional, contains provider-specific captcha token +- `captcha_answer_data`: optional, contains provider-specific captcha data +- `token`: invite token required when the registrations aren't public. + +## Instance + +`GET /api/v1/instance` has additional fields + +- `max_toot_chars`: The maximum characters per post +- `chat_limit`: The maximum characters per chat message +- `description_limit`: The maximum characters per image description +- `poll_limits`: The limits of polls +- `upload_limit`: The maximum upload file size +- `avatar_upload_limit`: The same for avatars +- `background_upload_limit`: The same for backgrounds +- `banner_upload_limit`: The same for banners +- `background_image`: A background image that frontends can use +- `pleroma.metadata.features`: A list of supported features +- `pleroma.metadata.federation`: The federation restrictions of this instance +- `pleroma.metadata.fields_limits`: A list of values detailing the length and count limitation for various instance-configurable fields. +- `pleroma.metadata.post_formats`: A list of the allowed post format types +- `vapid_public_key`: The public key needed for push messages + +## Push Subscription + +`POST /api/v1/push/subscription` +`PUT /api/v1/push/subscription` + +Permits these additional alert types: + +- pleroma:chat_mention +- pleroma:emoji_reaction + +## Markers + +Has these additional fields under the `pleroma` object: + +- `unread_count`: contains number unread notifications + +## Streaming + +### Chats + +There is an additional `user:pleroma_chat` stream. Incoming chat messages will make the current chat be sent to this `user` stream. The `event` of an incoming chat message is `pleroma:chat_update`. The payload is the updated chat with the incoming chat message in the `last_message` field. + +### Remote timelines + +For viewing remote server timelines, there are `public:remote` and `public:remote:media` streams. Each of these accept a parameter like `?instance=lain.com`. + +### Follow relationships updates + +Pleroma streams follow relationships updates as `pleroma:follow_relationships_update` events to the `user` stream. + +The message payload consist of: + +- `state`: a relationship state, one of `follow_pending`, `follow_accept` or `follow_reject`. + +- `follower` and `following` maps with following fields: + - `id`: user ID + - `follower_count`: follower count + - `following_count`: following count + +## User muting and thread muting + +Both user muting and thread muting can be done for only a certain time by adding an `expires_in` parameter to the API calls and giving the expiration time in seconds. + +## Not implemented + +Pleroma is generally compatible with the Mastodon 2.7.2 API, but some newer features and non-essential features are omitted. These features usually return an HTTP 200 status code, but with an empty response. While they may be added in the future, they are considered low priority. + +### Suggestions + +*Added in Mastodon 2.4.3* + +- `GET /api/v1/suggestions`: Returns an empty array, `[]` + +### Trends + +*Added in Mastodon 3.0.0* + +- `GET /api/v1/trends`: Returns an empty array, `[]` + +### Identity proofs + +*Added in Mastodon 2.8.0* + +- `GET /api/v1/identity_proofs`: Returns an empty array, `[]` + +### Endorsements + +*Added in Mastodon 2.5.0* + +- `GET /api/v1/endorsements`: Returns an empty array, `[]` + +### Profile directory + +*Added in Mastodon 3.0.0* + +- `GET /api/v1/directory`: Returns HTTP 404 + +### Featured tags + +*Added in Mastodon 3.0.0* + +- `GET /api/v1/featured_tags`: Returns HTTP 404 diff --git a/docs/development/API/pleroma_api.md b/docs/development/API/pleroma_api.md new file mode 100644 index 000000000..d8790ca32 --- /dev/null +++ b/docs/development/API/pleroma_api.md @@ -0,0 +1,655 @@ +# Pleroma API + +Requests that require it can be authenticated with [an OAuth token](https://tools.ietf.org/html/rfc6749), the `_pleroma_key` cookie, or [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization). + +Request parameters can be passed via [query strings](https://en.wikipedia.org/wiki/Query_string) or as [form data](https://www.w3.org/TR/html401/interact/forms.html). Files must be uploaded as `multipart/form-data`. + +## `/api/pleroma/emoji` +### Lists the custom emoji on that server. +* Method: `GET` +* Authentication: not required +* Params: none +* Response: JSON +* Example response: +```json +{ + "girlpower": { + "tags": [ + "Finmoji" + ], + "image_url": "/finmoji/128px/girlpower-128.png" + }, + "education": { + "tags": [ + "Finmoji" + ], + "image_url": "/finmoji/128px/education-128.png" + }, + "finnishlove": { + "tags": [ + "Finmoji" + ], + "image_url": "/finmoji/128px/finnishlove-128.png" + } +} +``` +* Note: Same data as Mastodon API’s `/api/v1/custom_emojis` but in a different format + +## `/api/pleroma/follow_import` +### Imports your follows, for example from a Mastodon CSV file. +* Method: `POST` +* Authentication: required +* Params: + * `list`: STRING or FILE containing a whitespace-separated list of accounts to follow +* Response: HTTP 200 on success, 500 on error +* Note: Users that can't be followed are silently skipped. + +## `/api/pleroma/blocks_import` +### Imports your blocks. +* Method: `POST` +* Authentication: required +* Params: + * `list`: STRING or FILE containing a whitespace-separated list of accounts to block +* Response: HTTP 200 on success, 500 on error + +## `/api/pleroma/mutes_import` +### Imports your mutes. +* Method: `POST` +* Authentication: required +* Params: + * `list`: STRING or FILE containing a whitespace-separated list of accounts to mute +* Response: HTTP 200 on success, 500 on error + +## `/api/pleroma/captcha` +### Get a new captcha +* Method: `GET` +* Authentication: not required +* Params: none +* Response: Provider specific JSON, the only guaranteed parameter is `type` +* Example response: `{"type": "kocaptcha", "token": "whatever", "url": "https://captcha.kotobank.ch/endpoint", "seconds_valid": 300}` + +## `/api/pleroma/delete_account` +### Delete an account +* Method `POST` +* Authentication: required +* Params: + * `password`: user's password +* Response: JSON. Returns `{"status": "success"}` if the deletion was successful, `{"error": "[error message]"}` otherwise +* Example response: `{"error": "Invalid password."}` + +## `/api/pleroma/disable_account` +### Disable an account +* Method `POST` +* Authentication: required +* Params: + * `password`: user's password +* Response: JSON. Returns `{"status": "success"}` if the account was successfully disabled, `{"error": "[error message]"}` otherwise +* Example response: `{"error": "Invalid password."}` + +## `/api/pleroma/accounts/mfa` +#### Gets current MFA settings +* method: `GET` +* Authentication: required +* OAuth scope: `read:security` +* Response: JSON. Returns `{"enabled": "false", "totp": false }` + +## `/api/pleroma/accounts/mfa/setup/totp` +#### Pre-setup the MFA/TOTP method +* method: `GET` +* Authentication: required +* OAuth scope: `write:security` +* Response: JSON. Returns `{"key": [secret_key], "provisioning_uri": "[qr code uri]" }` when successful, otherwise returns HTTP 422 `{"error": "error_msg"}` + +## `/api/pleroma/accounts/mfa/confirm/totp` +#### Confirms & enables MFA/TOTP support for user account. +* method: `POST` +* Authentication: required +* OAuth scope: `write:security` +* Params: + * `password`: user's password + * `code`: token from TOTP App +* Response: JSON. Returns `{}` if the enable was successful, HTTP 422 `{"error": "[error message]"}` otherwise + + +## `/api/pleroma/accounts/mfa/totp` +#### Disables MFA/TOTP method for user account. +* method: `DELETE` +* Authentication: required +* OAuth scope: `write:security` +* Params: + * `password`: user's password +* Response: JSON. Returns `{}` if the disable was successful, HTTP 422 `{"error": "[error message]"}` otherwise +* Example response: `{"error": "Invalid password."}` + +## `/api/pleroma/accounts/mfa/backup_codes` +#### Generstes backup codes MFA for user account. +* method: `GET` +* Authentication: required +* OAuth scope: `write:security` +* Response: JSON. Returns `{"codes": codes}`when successful, otherwise HTTP 422 `{"error": "[error message]"}` + +## `/api/pleroma/admin/` +See [Admin-API](admin_api.md) + +## `/api/v1/pleroma/notifications/read` +### Mark notifications as read +* Method `POST` +* Authentication: required +* Params (mutually exclusive): + * `id`: a single notification id to read + * `max_id`: read all notifications up to this id +* Response: Notification entity/Array of Notification entities that were read. In case of `max_id`, only the first 80 read notifications will be returned. + +## `/api/v1/pleroma/accounts/:id/subscribe` +### Subscribe to receive notifications for all statuses posted by a user +* Method `POST` +* Authentication: required +* Params: + * `id`: account id to subscribe to +* Response: JSON, returns a mastodon relationship object on success, otherwise returns `{"error": "error_msg"}` +* Example response: +```json +{ + "id": "abcdefg", + "following": true, + "followed_by": false, + "blocking": false, + "muting": false, + "muting_notifications": false, + "subscribing": true, + "requested": false, + "domain_blocking": false, + "showing_reblogs": true, + "endorsed": false +} +``` + +## `/api/v1/pleroma/accounts/:id/unsubscribe` +### Unsubscribe to stop receiving notifications from user statuses +* Method `POST` +* Authentication: required +* Params: + * `id`: account id to unsubscribe from +* Response: JSON, returns a mastodon relationship object on success, otherwise returns `{"error": "error_msg"}` +* Example response: +```json +{ + "id": "abcdefg", + "following": true, + "followed_by": false, + "blocking": false, + "muting": false, + "muting_notifications": false, + "subscribing": false, + "requested": false, + "domain_blocking": false, + "showing_reblogs": true, + "endorsed": false +} +``` + +## `/api/v1/pleroma/accounts/:id/favourites` +### Returns favorites timeline of any user +* Method `GET` +* Authentication: not required +* Params: + * `id`: the id of the account for whom to return results + * `limit`: optional, the number of records to retrieve + * `since_id`: optional, returns results that are more recent than the specified id + * `max_id`: optional, returns results that are older than the specified id +* Response: JSON, returns a list of Mastodon Status entities on success, otherwise returns `{"error": "error_msg"}` +* Example response: +```json +[ + { + "account": { + "id": "9hptFmUF3ztxYh3Svg", + "url": "https://pleroma.example.org/users/nick2", + "username": "nick2", + ... + }, + "application": {"name": "Web", "website": null}, + "bookmarked": false, + "card": null, + "content": "This is :moominmamma: note 0", + "created_at": "2019-04-15T15:42:15.000Z", + "emojis": [], + "favourited": false, + "favourites_count": 1, + "id": "9hptFmVJ02khbzYJaS", + "in_reply_to_account_id": null, + "in_reply_to_id": null, + "language": null, + "media_attachments": [], + "mentions": [], + "muted": false, + "pinned": false, + "pleroma": { + "content": {"text/plain": "This is :moominmamma: note 0"}, + "conversation_id": 13679, + "local": true, + "spoiler_text": {"text/plain": "2hu"} + }, + "reblog": null, + "reblogged": false, + "reblogs_count": 0, + "replies_count": 0, + "sensitive": false, + "spoiler_text": "2hu", + "tags": [{"name": "2hu", "url": "/tag/2hu"}], + "uri": "https://pleroma.example.org/objects/198ed2a1-7912-4482-b559-244a0369e984", + "url": "https://pleroma.example.org/notice/9hptFmVJ02khbzYJaS", + "visibility": "public" + } +] +``` + +## `/api/v1/pleroma/accounts/update_*` +### Set and clear account avatar, banner, and background + +- PATCH `/api/v1/pleroma/accounts/update_avatar`: Set/clear user avatar image +- PATCH `/api/v1/pleroma/accounts/update_banner`: Set/clear user banner image +- PATCH `/api/v1/pleroma/accounts/update_background`: Set/clear user background image + +## `/api/v1/pleroma/accounts/confirmation_resend` +### Resend confirmation email +* Method `POST` +* Params: + * `email`: email of that needs to be verified +* Authentication: not required +* Response: 204 No Content + +## `/api/v1/pleroma/mascot` +### Gets user mascot image +* Method `GET` +* Authentication: required + +* Response: JSON. Returns a mastodon media attachment entity. +* Example response: +```json +{ + "id": "abcdefg", + "url": "https://pleroma.example.org/media/abcdefg.png", + "type": "image", + "pleroma": { + "mime_type": "image/png" + } +} +``` + +### Updates user mascot image +* Method `PUT` +* Authentication: required +* Params: + * `file`: Multipart image +* Response: JSON. Returns a mastodon media attachment entity + when successful, otherwise returns HTTP 415 `{"error": "error_msg"}` +* Example response: +```json +{ + "id": "abcdefg", + "url": "https://pleroma.example.org/media/abcdefg.png", + "type": "image", + "pleroma": { + "mime_type": "image/png" + } +} +``` +* Note: Behaves exactly the same as `POST /api/v1/upload`. + Can only accept images - any attempt to upload non-image files will be met with `HTTP 415 Unsupported Media Type`. + +## `/api/pleroma/notification_settings` +### Updates user notification settings +* Method `PUT` +* Authentication: required +* Params: + * `block_from_strangers`: BOOLEAN field, blocks notifications from accounts you do not follow + * `hide_notification_contents`: BOOLEAN field. When set to true, it removes the contents of a message from the push notification. +* Response: JSON. Returns `{"status": "success"}` if the update was successful, otherwise returns `{"error": "error_msg"}` + +## `/api/pleroma/healthcheck` +### Healthcheck endpoint with additional system data. +* Method `GET` +* Authentication: not required +* Params: none +* Response: JSON, statuses (200 - healthy, 503 unhealthy). +* Example response: +```json +{ + "pool_size": 0, # database connection pool + "active": 0, # active processes + "idle": 0, # idle processes + "memory_used": 0.00, # Memory used + "healthy": true, # Instance state + "job_queue_stats": {} # Job queue stats +} +``` + +## `/api/pleroma/change_email` +### Change account email +* Method `POST` +* Authentication: required +* Params: + * `password`: user's password + * `email`: new email +* Response: JSON. Returns `{"status": "success"}` if the change was successful, `{"error": "[error message]"}` otherwise +* Note: Currently, Mastodon has no API for changing email. If they add it in future it might be incompatible with Pleroma. + +# Pleroma Conversations + +Pleroma Conversations have the same general structure that Mastodon Conversations have. The behavior differs in the following ways when using these endpoints: + +1. Pleroma Conversations never add or remove recipients, unless explicitly changed by the user. +2. Pleroma Conversations statuses can be requested by Conversation id. +3. Pleroma Conversations can be replied to. + +Conversations have the additional field `recipients` under the `pleroma` key. This holds a list of all the accounts that will receive a message in this conversation. + +The status posting endpoint takes an additional parameter, `in_reply_to_conversation_id`, which, when set, will set the visiblity to direct and address only the people who are the recipients of that Conversation. + +⚠ Conversation IDs can be found in direct messages with the `pleroma.direct_conversation_id` key, do not confuse it with `pleroma.conversation_id`. + +## `GET /api/v1/pleroma/conversations/:id/statuses` +### Timeline for a given conversation +* Method `GET` +* Authentication: required +* Params: Like other timelines +* Response: JSON, statuses (200 - healthy, 503 unhealthy). + +## `GET /api/v1/pleroma/conversations/:id` +### The conversation with the given ID. +* Method `GET` +* Authentication: required +* Params: None +* Response: JSON, statuses (200 - healthy, 503 unhealthy). + +## `PATCH /api/v1/pleroma/conversations/:id` +### Update a conversation. Used to change the set of recipients. +* Method `PATCH` +* Authentication: required +* Params: + * `recipients`: A list of ids of users that should receive posts to this conversation. This will replace the current list of recipients, so submit the full list. The owner of owner of the conversation will always be part of the set of recipients, though. +* Response: JSON, statuses (200 - healthy, 503 unhealthy) + +## `POST /api/v1/pleroma/conversations/read` +### Marks all user's conversations as read. +* Method `POST` +* Authentication: required +* Params: None +* Response: JSON, returns a list of Mastodon Conversation entities that were marked as read (200 - healthy, 503 unhealthy). + +## `GET /api/pleroma/emoji/pack?name=:name` + +### Get pack.json for the pack + +* Method `GET` +* Authentication: not required +* Params: + * `page`: page number for files (default 1) + * `page_size`: page size for files (default 30) +* Response: JSON, pack json with `files`, `files_count` and `pack` keys with 200 status or 404 if the pack does not exist. + +```json +{ + "files": {...}, + "files_count": 0, // emoji count in pack + "pack": {...} +} +``` + +## `POST /api/pleroma/emoji/pack?name=:name` + +### Creates an empty pack + +* Method `POST` +* Authentication: required (admin) +* Params: + * `name`: pack name +* Response: JSON, "ok" and 200 status or 409 if the pack with that name already exists + +## `PATCH /api/pleroma/emoji/pack?name=:name` + +### Updates (replaces) pack metadata + +* Method `PATCH` +* Authentication: required (admin) +* Params: + * `name`: pack name + * `metadata`: metadata to replace the old one + * `license`: Pack license + * `homepage`: Pack home page url + * `description`: Pack description + * `fallback-src`: Fallback url to download pack from + * `fallback-src-sha256`: SHA256 encoded for fallback pack archive + * `share-files`: is pack allowed for sharing (boolean) +* Response: JSON, updated "metadata" section of the pack and 200 status or 400 if there was a + problem with the new metadata (the error is specified in the "error" part of the response JSON) + +## `DELETE /api/pleroma/emoji/pack?name=:name` + +### Delete a custom emoji pack + +* Method `DELETE` +* Authentication: required (admin) +* Params: + * `name`: pack name +* Response: JSON, "ok" and 200 status or 500 if there was an error deleting the pack + +## `GET /api/pleroma/emoji/packs/import` + +### Imports packs from filesystem + +* Method `GET` +* Authentication: required (admin) +* Params: None +* Response: JSON, returns a list of imported packs. + +## `GET /api/pleroma/emoji/packs/remote` + +### Make request to another instance for packs list + +* Method `GET` +* Authentication: required (admin) +* Params: + * `url`: url of the instance to get packs from + * `page`: page number for packs (default 1) + * `page_size`: page size for packs (default 50) +* Response: JSON with the pack list, hashmap with pack name and pack contents + +## `POST /api/pleroma/emoji/packs/download` + +### Download pack from another instance + +* Method `POST` +* Authentication: required (admin) +* Params: + * `url`: url of the instance to download from + * `name`: pack to download from that instance + * `as`: (*optional*) name how to save pack +* Response: JSON, "ok" with 200 status if the pack was downloaded, or 500 if there were + errors downloading the pack + +## `POST /api/pleroma/emoji/packs/files?name=:name` + +### Add new file to the pack + +* Method `POST` +* Authentication: required (admin) +* Params: + * `name`: pack name + * `file`: file needs to be uploaded with the multipart request or link to remote file. + * `shortcode`: (*optional*) shortcode for new emoji, must be unique for all emoji. If not sended, shortcode will be taken from original filename. + * `filename`: (*optional*) new emoji file name. If not specified will be taken from original filename. +* Response: JSON, list of files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message. + +## `PATCH /api/pleroma/emoji/packs/files?name=:name` + +### Update emoji file from pack + +* Method `PATCH` +* Authentication: required (admin) +* Params: + * `name`: pack name + * `shortcode`: emoji file shortcode + * `new_shortcode`: new emoji file shortcode + * `new_filename`: new filename for emoji file + * `force`: (*optional*) with true value to overwrite existing emoji with new shortcode +* Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message. + +## `DELETE /api/pleroma/emoji/packs/files?name=:name` + +### Delete emoji file from pack + +* Method `DELETE` +* Authentication: required (admin) +* Params: + * `name`: pack name + * `shortcode`: emoji file shortcode +* Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message. + +## `GET /api/pleroma/emoji/packs` + +### Lists local custom emoji packs + +* Method `GET` +* Authentication: not required +* Params: + * `page`: page number for packs (default 1) + * `page_size`: page size for packs (default 50) +* Response: `packs` key with JSON hashmap of pack name to pack contents and `count` key for count of packs. + +```json +{ + "packs": { + "pack_name": {...}, // pack contents + ... + }, + "count": 0 // packs count +} +``` + +## `GET /api/pleroma/emoji/packs/archive?name=:name` + +### Requests a local pack archive from the instance + +* Method `GET` +* Authentication: not required +* Params: + * `name`: pack name +* Response: the archive of the pack with a 200 status code, 403 if the pack is not set as shared, + 404 if the pack does not exist + +## `GET /api/v1/pleroma/accounts/:id/scrobbles` +### Requests a list of current and recent Listen activities for an account +* Method `GET` +* Authentication: not required +* Params: None +* Response: An array of media metadata entities. +* Example response: +```json +[ + { + "account": {...}, + "id": "1234", + "title": "Some Title", + "artist": "Some Artist", + "album": "Some Album", + "length": 180000, + "created_at": "2019-09-28T12:40:45.000Z" + } +] +``` + +## `POST /api/v1/pleroma/scrobble` +### Creates a new Listen activity for an account +* Method `POST` +* Authentication: required +* Params: + * `title`: the title of the media playing + * `album`: the album of the media playing [optional] + * `artist`: the artist of the media playing [optional] + * `length`: the length of the media playing [optional] +* Response: the newly created media metadata entity representing the Listen activity + +# Emoji Reactions + +Emoji reactions work a lot like favourites do. They make it possible to react to a post with a single emoji character. To detect the presence of this feature, you can check `pleroma_emoji_reactions` entry in the features list of nodeinfo. + +## `PUT /api/v1/pleroma/statuses/:id/reactions/:emoji` +### React to a post with a unicode emoji +* Method: `PUT` +* Authentication: required +* Params: `emoji`: A unicode RGI emoji or a regional indicator +* Response: JSON, the status. + +## `DELETE /api/v1/pleroma/statuses/:id/reactions/:emoji` +### Remove a reaction to a post with a unicode emoji +* Method: `DELETE` +* Authentication: required +* Params: `emoji`: A unicode RGI emoji or a regional indicator +* Response: JSON, the status. + +## `GET /api/v1/pleroma/statuses/:id/reactions` +### Get an object of emoji to account mappings with accounts that reacted to the post +* Method: `GET` +* Authentication: optional +* Params: None +* Response: JSON, a list of emoji/account list tuples, sorted by emoji insertion date, in ascending order, e.g, the first emoji in the list is the oldest. +* Example Response: +```json +[ + {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]}, + {"name": "☕", "count": 1, "me": false, "accounts": [{"id" => "abc..."}]} +] +``` + +## `GET /api/v1/pleroma/statuses/:id/reactions/:emoji` +### Get an object of emoji to account mappings with accounts that reacted to the post for a specific emoji +* Method: `GET` +* Authentication: optional +* Params: None +* Response: JSON, a list of emoji/account list tuples +* Example Response: +```json +[ + {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]} +] +``` + +## `POST /api/v1/pleroma/backups` +### Create a user backup archive + +* Method: `POST` +* Authentication: required +* Params: none +* Response: JSON +* Example response: + +```json +[{ + "content_type": "application/zip", + "file_size": 0, + "inserted_at": "2020-09-10T16:18:03.000Z", + "processed": false, + "url": "https://example.com/media/backups/archive-foobar-20200910T161803-QUhx6VYDRQ2wfV0SdA2Pfj_2CLM_ATUlw-D5l5TJf4Q.zip" +}] +``` + +## `GET /api/v1/pleroma/backups` +### Lists user backups + +* Method: `GET` +* Authentication: not required +* Params: none +* Response: JSON +* Example response: + +```json +[{ + "content_type": "application/zip", + "file_size": 55457, + "inserted_at": "2020-09-10T16:18:03.000Z", + "processed": true, + "url": "https://example.com/media/backups/archive-foobar-20200910T161803-QUhx6VYDRQ2wfV0SdA2Pfj_2CLM_ATUlw-D5l5TJf4Q.zip" +}] +``` diff --git a/docs/development/API/prometheus.md b/docs/development/API/prometheus.md new file mode 100644 index 000000000..a5158d905 --- /dev/null +++ b/docs/development/API/prometheus.md @@ -0,0 +1,44 @@ +# Prometheus Metrics + +Pleroma includes support for exporting metrics via the [prometheus_ex](https://github.com/deadtrickster/prometheus.ex) library. + +Config example: + +``` +config :prometheus, Pleroma.Web.Endpoint.MetricsExporter, + enabled: true, + auth: {:basic, "myusername", "mypassword"}, + ip_whitelist: ["127.0.0.1"], + path: "/api/pleroma/app_metrics", + format: :text +``` + +* `enabled` (Pleroma extension) enables the endpoint +* `ip_whitelist` (Pleroma extension) could be used to restrict access only to specified IPs +* `auth` sets the authentication (`false` for no auth; configurable to HTTP Basic Auth, see [prometheus-plugs](https://github.com/deadtrickster/prometheus-plugs#exporting) documentation) +* `format` sets the output format (`:text` or `:protobuf`) +* `path` sets the path to app metrics page + + +## `/api/pleroma/app_metrics` + +### Exports Prometheus application metrics + +* Method: `GET` +* Authentication: not required by default (see configuration options above) +* Params: none +* Response: text + +## Grafana + +### Config example + +The following is a config example to use with [Grafana](https://grafana.com) + +``` + - job_name: 'beam' + metrics_path: /api/pleroma/app_metrics + scheme: https + static_configs: + - targets: ['pleroma.soykaf.com'] +``` diff --git a/docs/development/ap_extensions.md b/docs/development/ap_extensions.md new file mode 100644 index 000000000..3d1caeb3e --- /dev/null +++ b/docs/development/ap_extensions.md @@ -0,0 +1,65 @@ +# AP Extensions +## Actor endpoints + +The following endpoints are additionally present into our actors. + +- `oauthRegistrationEndpoint` (`http://litepub.social/ns#oauthRegistrationEndpoint`) +- `uploadMedia` (`https://www.w3.org/ns/activitystreams#uploadMedia`) + +### oauthRegistrationEndpoint + +Points to MastodonAPI `/api/v1/apps` for now. + +See + +### uploadMedia + +Inspired by , it is part of the ActivityStreams namespace because it used to be part of the ActivityPub specification and got removed from it. + +Content-Type: multipart/form-data + +Parameters: +- (required) `file`: The file being uploaded +- (optionnal) `description`: A plain-text description of the media, for accessibility purposes. + +Response: HTTP 201 Created with the object into the body, no `Location` header provided as it doesn't have an `id` + +The object given in the reponse should then be inserted into an Object's `attachment` field. + +## ChatMessages + +`ChatMessage`s are the messages sent in 1-on-1 chats. They are similar to +`Note`s, but the addresing is done by having a single AP actor in the `to` +field. Addressing multiple actors is not allowed. These messages are always +private, there is no public version of them. They are created with a `Create` +activity. + +They are part of the `litepub` namespace as `http://litepub.social/ns#ChatMessage`. + +Example: + +```json +{ + "actor": "http://2hu.gensokyo/users/raymoo", + "id": "http://2hu.gensokyo/objects/1", + "object": { + "attributedTo": "http://2hu.gensokyo/users/raymoo", + "content": "You expected a cute girl? Too bad.", + "id": "http://2hu.gensokyo/objects/2", + "published": "2020-02-12T14:08:20Z", + "to": [ + "http://2hu.gensokyo/users/marisa" + ], + "type": "ChatMessage" + }, + "published": "2018-02-12T14:08:20Z", + "to": [ + "http://2hu.gensokyo/users/marisa" + ], + "type": "Create" +} +``` + +This setup does not prevent multi-user chats, but these will have to go through +a `Group`, which will be the recipient of the messages and then `Announce` them +to the users in the `Group`. diff --git a/docs/development/authentication_authorization.md b/docs/development/authentication_authorization.md new file mode 100644 index 000000000..183bfc2c9 --- /dev/null +++ b/docs/development/authentication_authorization.md @@ -0,0 +1,21 @@ +# Authentication & Authorization + +## OAuth token-based authentication & authorization + +* Pleroma supports hierarchical OAuth scopes, just like Mastodon but with added granularity of admin scopes. For a reference, see [Mastodon OAuth scopes](https://docs.joinmastodon.org/api/oauth-scopes/). + +* It is important to either define OAuth scope restrictions or explicitly mark OAuth scope check as skipped, for every controller action. To define scopes, call `plug(Pleroma.Web.Plugs.OAuthScopesPlug, %{scopes: [...]})`. To explicitly set OAuth scopes check skipped, call `plug(:skip_plug, Pleroma.Web.Plugs.OAuthScopesPlug )`. + +* In controllers, `use Pleroma.Web, :controller` will result in `action/2` (see `Pleroma.Web.controller/0` for definition) be called prior to actual controller action, and it'll perform security / privacy checks before passing control to actual controller action. + + For routes with `:authenticated_api` pipeline, authentication & authorization are expected, thus `OAuthScopesPlug` will be run unless explicitly skipped (also `EnsureAuthenticatedPlug` will be executed immediately before action even if there was an early run to give an early error, since `OAuthScopesPlug` supports `:proceed_unauthenticated` option, and other plugs may support similar options as well). + + For `:api` pipeline routes, it'll be verified whether `OAuthScopesPlug` was called or explicitly skipped, and if it was not then auth information will be dropped for request. Then `EnsurePublicOrAuthenticatedPlug` will be called to ensure that either the instance is not private or user is authenticated (unless explicitly skipped). Such automated checks help to prevent human errors and result in higher security / privacy for users. + +## Non-OAuth authentication + +* With non-OAuth authentication ([HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization) or HTTP header- or params-provided auth), OAuth scopes check is _not_ performed for any action (since password is provided during the auth, requester is able to obtain a token with full permissions anyways); auth plugs invoke `Pleroma.Helpers.AuthHelper.skip_oauth(conn)` in this case. + +## Auth-related configuration, OAuth consumer mode etc. + +See `Authentication` section of [the configuration cheatsheet](../configuration/cheatsheet.md#authentication). diff --git a/docs/development/index.md b/docs/development/index.md new file mode 100644 index 000000000..01a617596 --- /dev/null +++ b/docs/development/index.md @@ -0,0 +1 @@ +This section contains notes and guidelines for developers. diff --git a/docs/development/setting_up_pleroma_dev.md b/docs/development/setting_up_pleroma_dev.md new file mode 100644 index 000000000..8da761d62 --- /dev/null +++ b/docs/development/setting_up_pleroma_dev.md @@ -0,0 +1,70 @@ +# Setting up a Pleroma development environment + +Pleroma requires some adjustments from the defaults for running the instance locally. The following should help you to get started. + +## Installing + +1. Install Pleroma as explained in [the docs](../installation/debian_based_en.md), with some exceptions: + * You can use your own fork of the repository and add pleroma as a remote `git remote add pleroma 'https://git.pleroma.social/pleroma/pleroma'` + * You can skip systemd and nginx and all that stuff + * No need to create a dedicated pleroma user, it's easier to just use your own user + * For the DB you can still choose a dedicated user, the mix tasks set it up for you so it's no extra work for you + * For domain you can use `localhost` + * instead of creating a `prod.secret.exs`, create `dev.secret.exs` + * No need to prefix with `MIX_ENV=prod`. We're using dev and that's the default MIX_ENV +2. Change the dev.secret.exs + * Change the scheme in `config :pleroma, Pleroma.Web.Endpoint` to http (see examples below) + * If you want to change other settings, you can do that too +3. You can now start the server `mix phx.server`. Once it's build and started, you can access the instance on `http://:` (e.g.http://localhost:4000 ) and should be able to do everything locally you normaly can. + +Example config to change the scheme to http. Change the port if you want to run on another port. +```elixir + config :pleroma, Pleroma.Web.Endpoint, + url: [host: "localhost", scheme: "http", port: 4000], +``` + +Example config to disable captcha. This makes it a bit easier to create test-users. +```elixir +config :pleroma, Pleroma.Captcha, + enabled: false +``` + +Example config to change the log level to info +```elixir +config :logger, :console, + # :debug :info :warning :error + level: :info +``` + +## Testing + +1. Create a `test.secret.exs` file with the content as shown below +2. Create the database user and test database. + 1. You can use the `config/setup_db.psql` as a template. Copy the file if you want and change the database name, user and password to the values for the test-database (e.g. 'pleroma_local_test' for database and user). Then run this file like you did during installation. + 2. The tests will try to create the Database, so we'll have to allow our test-database user to create databases, `sudo -Hu postgres psql -c "ALTER USER pleroma_local_test WITH CREATEDB;"` +3. Run the tests with `mix test`. The tests should succeed. + +Example content for the `test.secret.exs` file. Feel free to use another user, database name or password, just make sure the database is dedicated for the testing environment. +```elixir +# Pleroma test configuration + +# NOTE: This file should not be committed to a repo or otherwise made public +# without removing sensitive information. + +import Config + +config :pleroma, Pleroma.Repo, + username: "pleroma_local_test", + password: "mysuperduperpassword", + database: "pleroma_local_test", + hostname: "localhost" + +``` + +## Updating + +Update Pleroma as explained in [the docs](../administration/updating.md). Just make sure you pull from upstream and not from your own fork. + +## Working on multiple branches + +If you develop on a separate branch, it's possible you did migrations that aren't merged into another branch you're working on. If you have multiple things you're working on, it's probably best to set up multiple pleroma's each with their own database. If you finished with a branch and want to switch back to develop to start a new branch from there, you can drop the database and recreate the database (e.g. by using `config/setup_db.psql`). The commands to drop and recreate the database can be found in [the docs](../administration/backup.md). diff --git a/docs/installation/alpine_linux_en.md b/docs/installation/alpine_linux_en.md index 62f2fb778..2f8520a78 100644 --- a/docs/installation/alpine_linux_en.md +++ b/docs/installation/alpine_linux_en.md @@ -80,7 +80,7 @@ sudo /etc/init.d/postgresql start sudo rc-update add postgresql ``` -### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md)) +### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md)) ```shell sudo apk add ffmpeg imagemagick exiftool diff --git a/docs/installation/arch_linux_en.md b/docs/installation/arch_linux_en.md index 0eb6d2d5f..9cbd3f429 100644 --- a/docs/installation/arch_linux_en.md +++ b/docs/installation/arch_linux_en.md @@ -56,7 +56,7 @@ sudo -iu postgres initdb -D /var/lib/postgres/data sudo systemctl enable --now postgresql.service ``` -### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md)) +### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md)) ```shell sudo pacman -S ffmpeg imagemagick perl-image-exiftool diff --git a/docs/installation/debian_based_en.md b/docs/installation/debian_based_en.md index 2b1c7406f..926a85367 100644 --- a/docs/installation/debian_based_en.md +++ b/docs/installation/debian_based_en.md @@ -54,7 +54,7 @@ sudo apt update sudo apt install elixir erlang-dev erlang-nox ``` -### Optional packages: [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md) +### Optional packages: [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md) ```shell sudo apt install imagemagick ffmpeg libimage-exiftool-perl diff --git a/docs/installation/debian_based_jp.md b/docs/installation/debian_based_jp.md index 94e22325c..2613a86d9 100644 --- a/docs/installation/debian_based_jp.md +++ b/docs/installation/debian_based_jp.md @@ -54,7 +54,7 @@ sudo apt update sudo apt install elixir erlang-dev erlang-nox ``` -### オプションパッケージ: [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md) +### オプションパッケージ: [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md) ```shell sudo apt install imagemagick ffmpeg libimage-exiftool-perl diff --git a/docs/installation/freebsd_en.md b/docs/installation/freebsd_en.md index fdcb06c53..2dc466eb8 100644 --- a/docs/installation/freebsd_en.md +++ b/docs/installation/freebsd_en.md @@ -26,7 +26,7 @@ Setup the required services to automatically start at boot, using `sysrc(8)`. # service postgresql start ``` -### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md)) +### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md)) ```shell # pkg install imagemagick ffmpeg p5-Image-ExifTool diff --git a/docs/installation/netbsd_en.md b/docs/installation/netbsd_en.md index d5fa04fdf..233cf28b7 100644 --- a/docs/installation/netbsd_en.md +++ b/docs/installation/netbsd_en.md @@ -44,7 +44,7 @@ pgsql=YES First, run `# /etc/rc.d/pgsql start`. Then, `$ sudo -Hu pgsql -g pgsql createdb`. -### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md)) +### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md)) `# pkgin install ImageMagick ffmpeg4 p5-Image-ExifTool` diff --git a/docs/installation/openbsd_en.md b/docs/installation/openbsd_en.md index 8092ac379..0e1269ca5 100644 --- a/docs/installation/openbsd_en.md +++ b/docs/installation/openbsd_en.md @@ -27,7 +27,7 @@ Pleroma requires a reverse proxy, OpenBSD has relayd in base (and is used in thi #### Optional software -Per [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md): +Per [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md): * ImageMagick * ffmpeg * exiftool diff --git a/docs/installation/openbsd_fi.md b/docs/installation/openbsd_fi.md index 01cf34ab4..a61434147 100644 --- a/docs/installation/openbsd_fi.md +++ b/docs/installation/openbsd_fi.md @@ -20,7 +20,7 @@ Asenna tarvittava ohjelmisto: #### Optional software -[`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md): +[`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md): * ImageMagick * ffmpeg * exiftool diff --git a/priv/repo/optional_migrations/rum_indexing/20190510135645_add_fts_index_to_objects_two.exs b/priv/repo/optional_migrations/rum_indexing/20190510135645_add_fts_index_to_objects_two.exs index 757afa129..82e02281d 100644 --- a/priv/repo/optional_migrations/rum_indexing/20190510135645_add_fts_index_to_objects_two.exs +++ b/priv/repo/optional_migrations/rum_indexing/20190510135645_add_fts_index_to_objects_two.exs @@ -3,7 +3,14 @@ defmodule Pleroma.Repo.Migrations.AddFtsIndexToObjectsTwo do def up do execute("create extension if not exists rum") - drop_if_exists index(:objects, ["(to_tsvector('english', data->>'content'))"], using: :gin, name: :objects_fts) + + drop_if_exists( + index(:objects, ["(to_tsvector('english', data->>'content'))"], + using: :gin, + name: :objects_fts + ) + ) + alter table(:objects) do add(:fts_content, :tsvector) end @@ -14,7 +21,10 @@ defmodule Pleroma.Repo.Migrations.AddFtsIndexToObjectsTwo do return new; end $$ LANGUAGE plpgsql") - execute("create index if not exists objects_fts on objects using RUM (fts_content rum_tsvector_addon_ops, inserted_at) with (attach = 'inserted_at', to = 'fts_content');") + + execute( + "create index if not exists objects_fts on objects using RUM (fts_content rum_tsvector_addon_ops, inserted_at) with (attach = 'inserted_at', to = 'fts_content');" + ) execute("CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON objects FOR EACH ROW EXECUTE PROCEDURE objects_fts_update()") @@ -23,12 +33,19 @@ defmodule Pleroma.Repo.Migrations.AddFtsIndexToObjectsTwo do end def down do - execute "drop index if exists objects_fts" - execute "drop trigger if exists tsvectorupdate on objects" - execute "drop function if exists objects_fts_update()" + execute("drop index if exists objects_fts") + execute("drop trigger if exists tsvectorupdate on objects") + execute("drop function if exists objects_fts_update()") + alter table(:objects) do remove(:fts_content, :tsvector) end - create_if_not_exists index(:objects, ["(to_tsvector('english', data->>'content'))"], using: :gin, name: :objects_fts) + + create_if_not_exists( + index(:objects, ["(to_tsvector('english', data->>'content'))"], + using: :gin, + name: :objects_fts + ) + ) end end -- cgit v1.2.3 From 6b28121897bb9e864176b47d20f5d386c23859e4 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Sun, 10 Jan 2021 11:28:41 +0300 Subject: .formatter.exs: Format optional migrations (There are no changes to optional migrations since they were manually formatted in https://git.pleroma.social/pleroma/pleroma/-/merge_requests/3207) --- .formatter.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.formatter.exs b/.formatter.exs index 5799ac127..abd91dbbe 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,3 +1,3 @@ [ - inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}", "priv/repo/migrations/*.exs", "priv/scrubbers/*.ex"] + inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}", "priv/repo/migrations/*.exs", "priv/repo/optional_migrations/**/*.exs", "priv/scrubbers/*.ex"] ] -- cgit v1.2.3