Commit 89cba8f7 authored by Hakaba Hitoyo's avatar Hakaba Hitoyo

Merge branch 'develop' into deploy/20200129

parents c315d2a1 631eed87
Pipeline #23005 passed with stages
in 9 minutes
...@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ...@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **Breaking:** attachment links (`config :pleroma, :instance, no_attachment_links` and `config :pleroma, Pleroma.Upload, link_name`) disabled by default - **Breaking:** attachment links (`config :pleroma, :instance, no_attachment_links` and `config :pleroma, Pleroma.Upload, link_name`) disabled by default
- **Breaking:** OAuth: defaulted `[:auth, :enforce_oauth_admin_scope_usage]` setting to `true` which demands `admin` OAuth scope to perform admin actions (in addition to `is_admin` flag on User); make sure to use bundled or newer versions of AdminFE & PleromaFE to access admin / moderator features. - **Breaking:** OAuth: defaulted `[:auth, :enforce_oauth_admin_scope_usage]` setting to `true` which demands `admin` OAuth scope to perform admin actions (in addition to `is_admin` flag on User); make sure to use bundled or newer versions of AdminFE & PleromaFE to access admin / moderator features.
- **Breaking:** Dynamic configuration has been rearchitected. The `:pleroma, :instance, dynamic_configuration` setting has been replaced with `config :pleroma, configurable_from_database`. Please backup your configuration to a file and run the migration task to ensure consistency with the new schema. - **Breaking:** Dynamic configuration has been rearchitected. The `:pleroma, :instance, dynamic_configuration` setting has been replaced with `config :pleroma, configurable_from_database`. Please backup your configuration to a file and run the migration task to ensure consistency with the new schema.
- **Breaking:** `:instance, no_attachment_links` has been replaced with `:instance, attachment_links` which still takes a boolean value but doesn't use double negative language.
- Replaced [pleroma_job_queue](https://git.pleroma.social/pleroma/pleroma_job_queue) and `Pleroma.Web.Federator.RetryQueue` with [Oban](https://github.com/sorentwo/oban) (see [`docs/config.md`](docs/config.md) on migrating customized worker / retry settings) - Replaced [pleroma_job_queue](https://git.pleroma.social/pleroma/pleroma_job_queue) and `Pleroma.Web.Federator.RetryQueue` with [Oban](https://github.com/sorentwo/oban) (see [`docs/config.md`](docs/config.md) on migrating customized worker / retry settings)
- Introduced [quantum](https://github.com/quantum-elixir/quantum-core) job scheduler - Introduced [quantum](https://github.com/quantum-elixir/quantum-core) job scheduler
- Enabled `:instance, extended_nickname_format` in the default config - Enabled `:instance, extended_nickname_format` in the default config
...@@ -37,6 +38,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ...@@ -37,6 +38,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
<details> <details>
<summary>API Changes</summary> <summary>API Changes</summary>
- **Breaking** EmojiReactions: Change endpoints and responses to align with Mastodon
- **Breaking** Admin API: `PATCH /api/pleroma/admin/users/:nickname/force_password_reset` is now `PATCH /api/pleroma/admin/users/force_password_reset` (accepts `nicknames` array in the request body) - **Breaking** Admin API: `PATCH /api/pleroma/admin/users/:nickname/force_password_reset` is now `PATCH /api/pleroma/admin/users/force_password_reset` (accepts `nicknames` array in the request body)
- **Breaking:** Admin API: Return link alongside with token on password reset - **Breaking:** Admin API: Return link alongside with token on password reset
- **Breaking:** Admin API: `PUT /api/pleroma/admin/reports/:id` is now `PATCH /api/pleroma/admin/reports`, see admin_api.md for details - **Breaking:** Admin API: `PUT /api/pleroma/admin/reports/:id` is now `PATCH /api/pleroma/admin/reports`, see admin_api.md for details
......
...@@ -51,20 +51,6 @@ ...@@ -51,20 +51,6 @@
telemetry_event: [Pleroma.Repo.Instrumenter], telemetry_event: [Pleroma.Repo.Instrumenter],
migration_lock: nil migration_lock: nil
scheduled_jobs =
with digest_config <- Application.get_env(:pleroma, :email_notifications)[:digest],
true <- digest_config[:active] do
[{digest_config[:schedule], {Pleroma.Daemons.DigestEmailDaemon, :perform, []}}]
else
_ -> []
end
config :pleroma, Pleroma.Scheduler,
global: true,
overlap: true,
timezone: :utc,
jobs: scheduled_jobs
config :pleroma, Pleroma.Captcha, config :pleroma, Pleroma.Captcha,
enabled: true, enabled: true,
seconds_valid: 300, seconds_valid: 300,
...@@ -255,7 +241,7 @@ ...@@ -255,7 +241,7 @@
mrf_transparency_exclusions: [], mrf_transparency_exclusions: [],
autofollowed_nicknames: [], autofollowed_nicknames: [],
max_pinned_statuses: 1, max_pinned_statuses: 1,
no_attachment_links: true, attachment_links: false,
welcome_user_nickname: nil, welcome_user_nickname: nil,
welcome_message: nil, welcome_message: nil,
max_report_comment_size: 1000, max_report_comment_size: 1000,
...@@ -495,6 +481,12 @@ ...@@ -495,6 +481,12 @@
scheduled_activities: 10, scheduled_activities: 10,
background: 5, background: 5,
attachments_cleanup: 5 attachments_cleanup: 5
],
crontab: [
{"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker},
{"0 * * * *", Pleroma.Workers.Cron.StatsWorker},
{"* * * * *", Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker},
{"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker}
] ]
config :pleroma, :workers, config :pleroma, :workers,
...@@ -578,7 +570,6 @@ ...@@ -578,7 +570,6 @@
config :pleroma, :email_notifications, config :pleroma, :email_notifications,
digest: %{ digest: %{
active: false, active: false,
schedule: "0 0 * * 0",
interval: 7, interval: 7,
inactivity_threshold: 7 inactivity_threshold: 7
} }
...@@ -586,8 +577,7 @@ ...@@ -586,8 +577,7 @@
config :pleroma, :oauth2, config :pleroma, :oauth2,
token_expires_in: 600, token_expires_in: 600,
issue_new_refresh_token: true, issue_new_refresh_token: true,
clean_expired_tokens: false, clean_expired_tokens: false
clean_expired_tokens_interval: 86_400_000
config :pleroma, :database, rum_enabled: false config :pleroma, :database, rum_enabled: false
...@@ -622,7 +612,6 @@ ...@@ -622,7 +612,6 @@
config :pleroma, configurable_from_database: false config :pleroma, configurable_from_database: false
config :swarm, node_blacklist: [~r/myhtml_.*$/]
# Import environment specific config. This must remain at the bottom # Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above. # of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs" import_config "#{Mix.env()}.exs"
...@@ -637,22 +637,24 @@ ...@@ -637,22 +637,24 @@
%{ %{
key: :registrations_open, key: :registrations_open,
type: :boolean, type: :boolean,
description: "Enable registrations for anyone, invitations can be enabled when `false`" description:
"Enable registrations for anyone. Invitations require this setting to be disabled."
}, },
%{ %{
key: :invites_enabled, key: :invites_enabled,
type: :boolean, type: :boolean,
description: "Enable user invitations for admins (depends on `registrations_open: false`)" description:
"Enable user invitations for admins (depends on `registrations_open` being disabled)."
}, },
%{ %{
key: :account_activation_required, key: :account_activation_required,
type: :boolean, type: :boolean,
description: "Require users to confirm their emails before signing in" description: "Require users to confirm their emails before signing in."
}, },
%{ %{
key: :federating, key: :federating,
type: :boolean, type: :boolean,
description: "Enable federation with other instances" description: "Enable federation with other instances."
}, },
%{ %{
key: :federation_incoming_replies_max_depth, key: :federation_incoming_replies_max_depth,
...@@ -761,14 +763,14 @@ ...@@ -761,14 +763,14 @@
key: :extended_nickname_format, key: :extended_nickname_format,
type: :boolean, type: :boolean,
description: description:
"Set to `true` to use extended local nicknames format (allows underscores/dashes)." <> "Enable to use extended local nicknames format (allows underscores/dashes)." <>
" This will break federation with older software for theses nicknames." " This will break federation with older software for theses nicknames."
}, },
%{ %{
key: :cleanup_attachments, key: :cleanup_attachments,
type: :boolean, type: :boolean,
description: """ description: """
"Set to `true` to remove associated attachments when status is removed. "Enable to remove associated attachments when status is removed.
This will not affect duplicates and attachments without status. This will not affect duplicates and attachments without status.
Enabling this will increase load to database when deleting statuses on larger instances. Enabling this will increase load to database when deleting statuses on larger instances.
""" """
...@@ -796,10 +798,9 @@ ...@@ -796,10 +798,9 @@
] ]
}, },
%{ %{
key: :no_attachment_links, key: :attachment_links,
type: :boolean, type: :boolean,
description: description: "Enable to automatically add attachment link text to statuses"
"Set to `true` to disable automatically adding attachment link text to statuses"
}, },
%{ %{
key: :welcome_message, key: :welcome_message,
...@@ -830,14 +831,14 @@ ...@@ -830,14 +831,14 @@
key: :safe_dm_mentions, key: :safe_dm_mentions,
type: :boolean, type: :boolean,
description: description:
"If set to `true`, only mentions at the beginning of a post will be used to address people in direct messages." <> "If enabled, only mentions at the beginning of a post will be used to address people in direct messages." <>
" This is to prevent accidental mentioning of people when talking about them (e.g. \"@admin please keep an eye on @bad_actor\")." <> " This is to prevent accidental mentioning of people when talking about them (e.g. \"@admin please keep an eye on @bad_actor\")." <>
" Default: `false`" " Default: disabled"
}, },
%{ %{
key: :healthcheck, key: :healthcheck,
type: :boolean, type: :boolean,
description: "If set to `true`, system data will be shown on /api/pleroma/healthcheck" description: "If enabled, system data will be shown on /api/pleroma/healthcheck"
}, },
%{ %{
key: :remote_post_retention_days, key: :remote_post_retention_days,
...@@ -867,7 +868,7 @@ ...@@ -867,7 +868,7 @@
%{ %{
key: :skip_thread_containment, key: :skip_thread_containment,
type: :boolean, type: :boolean,
description: "Skip filter out broken threads. Default: `true`" description: "Skip filtering out broken threads. Default: enabled"
}, },
%{ %{
key: :limit_to_local_content, key: :limit_to_local_content,
...@@ -1159,17 +1160,15 @@ ...@@ -1159,17 +1160,15 @@
key: :alwaysShowSubjectInput, key: :alwaysShowSubjectInput,
label: "Always show subject input", label: "Always show subject input",
type: :boolean, type: :boolean,
description: "When set to `false`, auto-hide the subject field when it's empty" description: "When disabled, auto-hide the subject field if it's empty"
}, },
%{ %{
key: :logoMask, key: :logoMask,
label: "Logo mask", label: "Logo mask",
type: :boolean, type: :boolean,
description: description:
"By default it assumes logo used will be monochrome-with-alpha one, this is done to be compatible with both light and dark themes, " <> "By default it assumes logo used will be monochrome with alpha channel to be compatible with both light and dark themes. " <>
"so that white logo designed with dark theme in mind won't be invisible over light theme, this is done via CSS3 Masking. " <> "If you want a colorful logo you must disable logoMask."
"Basically - it will take alpha channel of the image and fill non-transparent areas of it with solid color. " <>
"If you really want colorful logo - it can be done by setting logoMask to false."
}, },
%{ %{
key: :logoMargin, key: :logoMargin,
...@@ -1183,13 +1182,13 @@ ...@@ -1183,13 +1182,13 @@
%{ %{
key: :stickers, key: :stickers,
type: :boolean, type: :boolean,
description: "Enables/disables stickers." description: "Enables stickers."
}, },
%{ %{
key: :enableEmojiPicker, key: :enableEmojiPicker,
label: "Emoji picker", label: "Emoji picker",
type: :boolean, type: :boolean,
description: "Enables/disables emoji picker." description: "Enables emoji picker."
} }
] ]
}, },
...@@ -2086,7 +2085,7 @@ ...@@ -2086,7 +2085,7 @@
key: :unfurl_nsfw, key: :unfurl_nsfw,
label: "Unfurl NSFW", label: "Unfurl NSFW",
type: :boolean, type: :boolean,
description: "If set to `true` NSFW attachments will be shown in previews" description: "When enabled NSFW attachments will be shown in previews"
} }
] ]
}, },
...@@ -2358,7 +2357,7 @@ ...@@ -2358,7 +2357,7 @@
type: :boolean, type: :boolean,
description: description:
"OAuth admin scope requirement toggle. " <> "OAuth admin scope requirement toggle. " <>
"If `true`, admin actions explicitly demand admin OAuth scope(s) presence in OAuth token " <> "If enabled, 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)," <> "(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." "`is_admin` user flag grants access to admin-specific actions."
}, },
...@@ -2519,13 +2518,6 @@ ...@@ -2519,13 +2518,6 @@
key: :clean_expired_tokens, key: :clean_expired_tokens,
type: :boolean, type: :boolean,
description: "Enable a background job to clean expired oauth tokens. Default: `false`." description: "Enable a background job to clean expired oauth tokens. Default: `false`."
},
%{
key: :clean_expired_tokens_interval,
type: :integer,
description:
"Interval to run the job to clean expired tokens. Default: 86_400_000 (24 hours).",
suggestions: [86_400_000]
} }
] ]
}, },
......
...@@ -66,11 +66,8 @@ ...@@ -66,11 +66,8 @@
config :pleroma, Oban, config :pleroma, Oban,
queues: false, queues: false,
prune: :disabled prune: :disabled,
crontab: false
config :pleroma, Pleroma.Scheduler,
jobs: [],
global: false
config :pleroma, Pleroma.ScheduledActivity, config :pleroma, Pleroma.ScheduledActivity,
daily_user_limit: 2, daily_user_limit: 2,
......
...@@ -29,7 +29,7 @@ Has these additional fields under the `pleroma` object: ...@@ -29,7 +29,7 @@ Has these additional fields under the `pleroma` object:
- `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being it's 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 it's 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 - `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 - `thread_muted`: true if the thread the post belongs to is muted
- `emoji_reactions`: A list with emoji / reaction maps. The format is `{emoji: "☕", count: 1, reacted: true}`. Contains no information about the reacting users, for that use the `emoji_reactions_by` endpoint. - `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.
## Attachments ## Attachments
...@@ -88,6 +88,9 @@ Behavior has changed: ...@@ -88,6 +88,9 @@ Behavior has changed:
- `/api/v1/accounts/search`: Does not require authentication - `/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 ## Notifications
......
...@@ -432,21 +432,21 @@ The status posting endpoint takes an additional parameter, `in_reply_to_conversa ...@@ -432,21 +432,21 @@ The status posting endpoint takes an additional parameter, `in_reply_to_conversa
Emoji reactions work a lot like favourites do. They make it possible to react to a post with a single emoji character. Emoji reactions work a lot like favourites do. They make it possible to react to a post with a single emoji character.
## `POST /api/v1/pleroma/statuses/:id/react_with_emoji` ## `PUT /api/v1/pleroma/statuses/:id/reactions/:emoji`
### React to a post with a unicode emoji ### React to a post with a unicode emoji
* Method: `POST` * Method: `PUT`
* Authentication: required * Authentication: required
* Params: `emoji`: A single character unicode emoji * Params: `emoji`: A single character unicode emoji
* Response: JSON, the status. * Response: JSON, the status.
## `POST /api/v1/pleroma/statuses/:id/unreact_with_emoji` ## `DELETE /api/v1/pleroma/statuses/:id/reactions/:emoji`
### Remove a reaction to a post with a unicode emoji ### Remove a reaction to a post with a unicode emoji
* Method: `POST` * Method: `DELETE`
* Authentication: required * Authentication: required
* Params: `emoji`: A single character unicode emoji * Params: `emoji`: A single character unicode emoji
* Response: JSON, the status. * Response: JSON, the status.
## `GET /api/v1/pleroma/statuses/:id/emoji_reactions_by` ## `GET /api/v1/pleroma/statuses/:id/reactions`
### Get an object of emoji to account mappings with accounts that reacted to the post ### Get an object of emoji to account mappings with accounts that reacted to the post
* Method: `GET` * Method: `GET`
* Authentication: optional * Authentication: optional
...@@ -455,7 +455,7 @@ Emoji reactions work a lot like favourites do. They make it possible to react to ...@@ -455,7 +455,7 @@ Emoji reactions work a lot like favourites do. They make it possible to react to
* Example Response: * Example Response:
```json ```json
[ [
{"emoji": "😀", "count": 2, "reacted": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]}, {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]},
{"emoji": "☕", "count": 1, "reacted": false, "accounts": [{"id" => "abc..."}]} {"name": "☕", "count": 1, "me": false, "accounts": [{"id" => "abc..."}]}
] ]
``` ```
# Backup/Restore your instance # Backup/Restore/Move/Remove your instance
## Backup ## Backup
1. Stop the Pleroma service. 1. Stop the Pleroma service.
2. Go to the working directory of Pleroma (default is `/opt/pleroma`) 2. Go to the working directory of Pleroma (default is `/opt/pleroma`)
3. Run `sudo -Hu postgres pg_dump -d <pleroma_db> --format=custom -f </path/to/backup_location/pleroma.pgdump>` 3. Run `sudo -Hu postgres pg_dump -d <pleroma_db> --format=custom -f </path/to/backup_location/pleroma.pgdump>` (make sure the postgres user has write access to the destination file)
4. Copy `pleroma.pgdump`, `config/prod.secret.exs` and the `uploads` folder to your backup destination. If you have other modifications, copy those changes too. 4. Copy `pleroma.pgdump`, `config/prod.secret.exs` and the `uploads` folder to your backup destination. If you have other modifications, copy those changes too.
5. Restart the Pleroma service. 5. Restart the Pleroma service.
## Restore ## Restore/Move
1. Stop the Pleroma service. 1. Optionally reinstall Pleroma (either on the same server or on another server if you want to move servers). Try to use the same database name.
2. Go to the working directory of Pleroma (default is `/opt/pleroma`) 2. Stop the Pleroma service.
3. Copy the above mentioned files back to their original position. 3. Go to the working directory of Pleroma (default is `/opt/pleroma`)
4. Run `sudo -Hu postgres pg_restore -d <pleroma_db> -v -1 </path/to/backup_location/pleroma.pgdump>` 4. Copy the above mentioned files back to their original position.
5. Restart the Pleroma service. 5. Drop the existing database and recreate an empty one `sudo -Hu postgres psql -c 'DROP DATABASE <pleroma_db>;';` `sudo -Hu postgres psql -c 'CREATE DATABASE <pleroma_db>;';`
6. Run `sudo -Hu postgres pg_restore -d <pleroma_db> -v -1 </path/to/backup_location/pleroma.pgdump>`
7. If you installed a newer Pleroma version, you should run `mix ecto.migrate`[^1]. This task performs database migrations, if there were any.
8. Restart the Pleroma service.
[^1]: Prefix with `MIX_ENV=prod` to run it using the production config file.
## Remove
1. Optionally you can remove the users of your instance. This will trigger delete requests for their accounts and posts. Note that this is 'best effort' and doesn't mean that all traces of your instance will be gone from the fediverse.
* You can do this from the admin-FE where you can select all local users and delete the accounts using the *Moderate multiple users* dropdown.
* You can also list local users and delete them individualy using the CLI tasks for [Managing users](./CLI_tasks/user.md).
2. Stop the Pleroma service `systemctl stop pleroma`
3. Disable pleroma from systemd `systemctl disable pleroma`
4. Remove the files and folders you created during installation (see installation guide). This includes the pleroma, nginx and systemd files and folders.
5. Reload nginx now that the configuration is removed `systemctl reload nginx`
6. Remove the database and database user `sudo -Hu postgres psql -c 'DROP DATABASE <pleroma_db>;';` `sudo -Hu postgres psql -c 'DROP USER <pleroma_db>;';`
7. Remove the system user `userdel pleroma`
8. Remove the dependencies that you don't need anymore (see installation guide). Make sure you don't remove packages that are still needed for other software that you have running!
...@@ -37,6 +37,11 @@ Feel free to contact us to be added to this list! ...@@ -37,6 +37,11 @@ Feel free to contact us to be added to this list!
- Platforms: Android - Platforms: Android
- Features: Streaming Ready, Moderation, Text Formatting - Features: Streaming Ready, Moderation, Text Formatting
### Kyclos
- Source Code: <https://git.pleroma.social/pleroma/harbour-kyclos>
- Platforms: SailfishOS
- Features: No Streaming
### Nekonium ### Nekonium
- Homepage: [F-Droid Repository](https://repo.gdgd.jp.net/), [Google Play](https://play.google.com/store/apps/details?id=com.apps.nekonium), [Amazon](https://www.amazon.co.jp/dp/B076FXPRBC/) - Homepage: [F-Droid Repository](https://repo.gdgd.jp.net/), [Google Play](https://play.google.com/store/apps/details?id=com.apps.nekonium), [Amazon](https://www.amazon.co.jp/dp/B076FXPRBC/)
- Source: <https://gogs.gdgd.jp.net/lin/nekonium> - Source: <https://gogs.gdgd.jp.net/lin/nekonium>
......
...@@ -513,6 +513,7 @@ Configuration options described in [Oban readme](https://github.com/sorentwo/oba ...@@ -513,6 +513,7 @@ Configuration options described in [Oban readme](https://github.com/sorentwo/oba
* `verbose` - logs verbosity * `verbose` - logs verbosity
* `prune` - non-retryable jobs [pruning settings](https://github.com/sorentwo/oban#pruning) (`:disabled` / `{:maxlen, value}` / `{:maxage, value}`) * `prune` - non-retryable jobs [pruning settings](https://github.com/sorentwo/oban#pruning) (`:disabled` / `{:maxlen, value}` / `{:maxage, value}`)
* `queues` - job queues (see below) * `queues` - job queues (see below)
* `crontab` - periodic jobs, see [`Oban.Cron`](#obancron)
Pleroma has the following queues: Pleroma has the following queues:
...@@ -524,6 +525,12 @@ Pleroma has the following queues: ...@@ -524,6 +525,12 @@ Pleroma has the following queues:
* `web_push` - Web push notifications * `web_push` - Web push notifications
* `scheduled_activities` - Scheduled activities, see [`Pleroma.ScheduledActivity`](#pleromascheduledactivity) * `scheduled_activities` - Scheduled activities, see [`Pleroma.ScheduledActivity`](#pleromascheduledactivity)
#### Oban.Cron
Pleroma has these periodic job workers:
`Pleroma.Workers.Cron.ClearOauthTokenWorker` - a job worker to cleanup expired oauth tokens.
Example: Example:
```elixir ```elixir
...@@ -534,6 +541,9 @@ config :pleroma, Oban, ...@@ -534,6 +541,9 @@ config :pleroma, Oban,
queues: [ queues: [
federator_incoming: 50, federator_incoming: 50,
federator_outgoing: 50 federator_outgoing: 50
],
crontab: [
{"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker}
] ]
``` ```
...@@ -816,8 +826,7 @@ Configure OAuth 2 provider capabilities: ...@@ -816,8 +826,7 @@ Configure OAuth 2 provider capabilities:
* `token_expires_in` - The lifetime in seconds of the access token. * `token_expires_in` - The lifetime in seconds of the access token.
* `issue_new_refresh_token` - Keeps old refresh token or generate new refresh token when to obtain an access token. * `issue_new_refresh_token` - Keeps old refresh token or generate new refresh token when to obtain an access token.
* `clean_expired_tokens` - Enable a background job to clean expired oauth tokens. Defaults to `false`. * `clean_expired_tokens` - Enable a background job to clean expired oauth tokens. Defaults to `false`. Interval settings sets in configuration periodic jobs [`Oban.Cron`](#obancron)
* `clean_expired_tokens_interval` - Interval to run the job to clean expired tokens. Defaults to `86_400_000` (24 hours).
## Link parsing ## Link parsing
......
...@@ -62,6 +62,6 @@ def validate_scheduled_at(changeset) do ...@@ -62,6 +62,6 @@ def validate_scheduled_at(changeset) do
def expires_late_enough?(scheduled_at) do def expires_late_enough?(scheduled_at) do
now = NaiveDateTime.utc_now() now = NaiveDateTime.utc_now()
diff = NaiveDateTime.diff(scheduled_at, now, :millisecond) diff = NaiveDateTime.diff(scheduled_at, now, :millisecond)
diff >= @min_activity_lifetime diff > @min_activity_lifetime
end end
end end
...@@ -42,12 +42,9 @@ def start(_type, _args) do ...@@ -42,12 +42,9 @@ def start(_type, _args) do
children = children =
[ [
Pleroma.Repo, Pleroma.Repo,
Pleroma.Scheduler,
Pleroma.Config.TransferTask, Pleroma.Config.TransferTask,
Pleroma.Emoji, Pleroma.Emoji,
Pleroma.Captcha, Pleroma.Captcha,
Pleroma.Daemons.ScheduledActivityDaemon,
Pleroma.Daemons.ActivityExpirationDaemon,
Pleroma.Plugs.RateLimiter.Supervisor Pleroma.Plugs.RateLimiter.Supervisor
] ++ ] ++
cachex_children() ++ cachex_children() ++
...@@ -58,7 +55,6 @@ def start(_type, _args) do ...@@ -58,7 +55,6 @@ def start(_type, _args) do
{Oban, Pleroma.Config.get(Oban)} {Oban, Pleroma.Config.get(Oban)}
] ++ ] ++
task_children(@env) ++ task_children(@env) ++
oauth_cleanup_child(oauth_cleanup_enabled?()) ++
streamer_child(@env) ++ streamer_child(@env) ++
chat_child(@env, chat_enabled?()) ++ chat_child(@env, chat_enabled?()) ++
[ [
...@@ -160,20 +156,12 @@ defp build_cachex(type, opts), ...@@ -160,20 +156,12 @@ defp build_cachex(type, opts),
defp chat_enabled?, do: Pleroma.Config.get([:chat, :enabled]) defp chat_enabled?, do: Pleroma.Config.get([:chat, :enabled])
defp oauth_cleanup_enabled?,
do: Pleroma.Config.get([:oauth2, :clean_expired_tokens], false)
defp streamer_child(:test), do: [] defp streamer_child(:test), do: []
defp streamer_child(_) do defp streamer_child(_) do
[Pleroma.Web.Streamer.supervisor()] [Pleroma.Web.Streamer.supervisor()]
end end
defp oauth_cleanup_child(true),
do: [Pleroma.Web.OAuth.Token.CleanWorker]
defp oauth_cleanup_child(_), do: []
defp chat_child(_env, true) do defp chat_child(_env, true) do
[Pleroma.Web.ChatChannel.ChatChannelState] [Pleroma.Web.ChatChannel.ChatChannelState]
end end
......
# Pleroma: A lightweight social networking server
# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Daemons.ActivityExpirationDaemon do
alias Pleroma.Activity
alias Pleroma.ActivityExpiration
alias Pleroma.Config
alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.Web.CommonAPI
require Logger
use GenServer
import Ecto.Query
@schedule_interval :timer.minutes(1)
def start_link(_) do