Browse Source

Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into display-name

merge-requests/3092/head
Sean King 3 years ago
parent
commit
2b4346baa0
100 changed files with 1039 additions and 465 deletions
  1. +1
    -1
      .formatter.exs
  2. +5
    -3
      .gitattributes
  3. +2
    -1
      .gitignore
  4. +48
    -11
      CHANGELOG.md
  5. +1
    -1
      COPYING
  6. +3
    -3
      benchmarks/load_testing/users.ex
  7. +1
    -1
      benchmarks/mix/tasks/pleroma/benchmarks/timelines.ex
  8. +22
    -17
      config/config.exs
  9. +71
    -138
      config/description.exs
  10. +2
    -0
      config/emoji.txt
  11. +19
    -7
      config/test.exs
  12. +109
    -1
      docs/administration/CLI_tasks/config.md
  13. +3
    -4
      docs/administration/CLI_tasks/email.md
  14. +2
    -2
      docs/administration/CLI_tasks/user.md
  15. +13
    -4
      docs/configuration/cheatsheet.md
  16. +50
    -48
      docs/configuration/howto_database_config.md
  17. +23
    -0
      docs/configuration/mrf.md
  18. +22
    -5
      docs/configuration/postgresql.md
  19. +5
    -0
      docs/configuration/static_dir.md
  20. +1
    -0
      docs/development/API/admin_api.md
  21. +0
    -0
      docs/development/API/chats.md
  22. +23
    -5
      docs/development/API/differences_in_mastoapi_responses.md
  23. +2
    -2
      docs/development/API/pleroma_api.md
  24. +0
    -0
      docs/development/API/prometheus.md
  25. +0
    -0
      docs/development/ap_extensions.md
  26. +3
    -28
      docs/development/authentication_authorization.md
  27. +1
    -0
      docs/development/index.md
  28. +70
    -0
      docs/development/setting_up_pleroma_dev.md
  29. +1
    -1
      docs/installation/alpine_linux_en.md
  30. +1
    -1
      docs/installation/arch_linux_en.md
  31. +1
    -1
      docs/installation/debian_based_en.md
  32. +1
    -1
      docs/installation/debian_based_jp.md
  33. +1
    -1
      docs/installation/freebsd_en.md
  34. +1
    -1
      docs/installation/netbsd_en.md
  35. +1
    -1
      docs/installation/openbsd_en.md
  36. +1
    -1
      docs/installation/openbsd_fi.md
  37. +2
    -11
      docs/installation/otp_en.md
  38. +13
    -10
      installation/download-mastofe-build.sh
  39. +0
    -9
      lib/jason_types.ex
  40. +16
    -9
      lib/mix/pleroma.ex
  41. +1
    -1
      lib/mix/tasks/pleroma/app.ex
  42. +1
    -1
      lib/mix/tasks/pleroma/benchmark.ex
  43. +281
    -50
      lib/mix/tasks/pleroma/config.ex
  44. +1
    -1
      lib/mix/tasks/pleroma/count_statuses.ex
  45. +10
    -4
      lib/mix/tasks/pleroma/database.ex
  46. +1
    -1
      lib/mix/tasks/pleroma/digest.ex
  47. +1
    -1
      lib/mix/tasks/pleroma/docs.ex
  48. +1
    -1
      lib/mix/tasks/pleroma/ecto.ex
  49. +1
    -1
      lib/mix/tasks/pleroma/ecto/migrate.ex
  50. +1
    -1
      lib/mix/tasks/pleroma/ecto/rollback.ex
  51. +2
    -2
      lib/mix/tasks/pleroma/email.ex
  52. +1
    -1
      lib/mix/tasks/pleroma/emoji.ex
  53. +1
    -1
      lib/mix/tasks/pleroma/frontend.ex
  54. +13
    -4
      lib/mix/tasks/pleroma/instance.ex
  55. +1
    -1
      lib/mix/tasks/pleroma/notification_settings.ex
  56. +1
    -1
      lib/mix/tasks/pleroma/refresh_counter_cache.ex
  57. +1
    -1
      lib/mix/tasks/pleroma/relay.ex
  58. +1
    -1
      lib/mix/tasks/pleroma/robots_txt.ex
  59. +1
    -1
      lib/mix/tasks/pleroma/uploads.ex
  60. +12
    -12
      lib/mix/tasks/pleroma/user.ex
  61. +1
    -1
      lib/phoenix/transports/web_socket/raw.ex
  62. +18
    -3
      lib/pleroma/activity.ex
  63. +2
    -2
      lib/pleroma/activity/ir/topics.ex
  64. +1
    -1
      lib/pleroma/activity/queries.ex
  65. +1
    -1
      lib/pleroma/activity/search.ex
  66. +12
    -3
      lib/pleroma/application.ex
  67. +26
    -1
      lib/pleroma/application_requirements.ex
  68. +1
    -1
      lib/pleroma/bbs/authenticator.ex
  69. +1
    -1
      lib/pleroma/bbs/handler.ex
  70. +1
    -1
      lib/pleroma/bookmark.ex
  71. +19
    -0
      lib/pleroma/caching.ex
  72. +5
    -3
      lib/pleroma/captcha.ex
  73. +1
    -1
      lib/pleroma/captcha/kocaptcha.ex
  74. +1
    -1
      lib/pleroma/captcha/native.ex
  75. +1
    -1
      lib/pleroma/captcha/service.ex
  76. +1
    -1
      lib/pleroma/chat.ex
  77. +1
    -1
      lib/pleroma/chat/message_reference.ex
  78. +1
    -1
      lib/pleroma/clippy.ex
  79. +6
    -1
      lib/pleroma/config.ex
  80. +24
    -2
      lib/pleroma/config/deprecation_warnings.ex
  81. +8
    -0
      lib/pleroma/config/getting.ex
  82. +1
    -1
      lib/pleroma/config/helpers.ex
  83. +1
    -1
      lib/pleroma/config/holder.ex
  84. +1
    -1
      lib/pleroma/config/loader.ex
  85. +1
    -1
      lib/pleroma/config/oban.ex
  86. +1
    -1
      lib/pleroma/config/transfer_task.ex
  87. +13
    -3
      lib/pleroma/config_db.ex
  88. +1
    -1
      lib/pleroma/constants.ex
  89. +3
    -2
      lib/pleroma/conversation.ex
  90. +1
    -1
      lib/pleroma/conversation/participation.ex
  91. +1
    -1
      lib/pleroma/conversation/participation/recipient_ship.ex
  92. +1
    -1
      lib/pleroma/counter_cache.ex
  93. +1
    -1
      lib/pleroma/delivery.ex
  94. +1
    -1
      lib/pleroma/docs/generator.ex
  95. +1
    -1
      lib/pleroma/docs/json.ex
  96. +1
    -1
      lib/pleroma/docs/markdown.ex
  97. +1
    -1
      lib/pleroma/earmark_renderer.ex
  98. +1
    -1
      lib/pleroma/ecto_enums.ex
  99. +1
    -1
      lib/pleroma/ecto_type/activity_pub/object_validators/date_time.ex
  100. +1
    -1
      lib/pleroma/ecto_type/activity_pub/object_validators/emoji.ex

+ 1
- 1
.formatter.exs View File

@@ -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"]
]

+ 5
- 3
.gitattributes View File

@@ -1,8 +1,10 @@
*.ex diff=elixir
*.exs diff=elixir
# At the time of writing all js/css files included
# in the repo are minified bundles, and we don't want
# to search/diff those as text files.

priv/static/instance/static.css diff=css

# Most of js/css files included in the repo are minified bundles,
# and we don't want to search/diff those as text files.
*.js binary
*.js.map binary
*.css binary

+ 2
- 1
.gitignore View File

@@ -3,6 +3,7 @@
/db
/deps
/*.ez
/test/instance
/test/uploads
/.elixir_ls
/test/fixtures/DSCN0010_tmp.jpg
@@ -31,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


+ 48
- 11
CHANGELOG.md View File

@@ -8,21 +8,34 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed

- **Breaking:** Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm`
- **Breaking**: AdminAPI changed User field `confirmation_pending` to `is_confirmed`
- **Breaking**: AdminAPI changed User field `approval_pending` to `is_approved`
- Polls now always return a `voters_count`, even if they are single-choice.
- Admin Emails: The ap id is used as the user link in emails now.
- Improved registration workflow for email confirmation and account approval modes.
- Search: When using Postgres 11+, Pleroma will use the `websearch_to_tsvector` function to parse search queries.
- Emoji: Support the full Unicode 13.1 set of Emoji for reactions, plus regional indicators.
- Admin API: Reports now ordered by newest
- Deprecated `Pleroma.Uploaders.S3, :public_endpoint`. Now `Pleroma.Upload, :base_url` is the standard configuration key for all uploaders.

### Added

- Reports now generate notifications for admins and mods.
- Experimental websocket-based federation between Pleroma instances.
- Support for local-only statuses
- Support for local-only statuses.
- Support pagination of blocks and mutes.
- Account backup.
- Configuration: Add `:instance, autofollowing_nicknames` setting to provide a way to make accounts automatically follow new users that register on the local Pleroma instance.
- Ability to view remote timelines, with ex. `/api/v1/timelines/public?instance=lain.com` and streams `public:remote` and `public:remote:media`.
- The site title is now injected as a `title` tag like preloads or metadata.
- Password reset tokens now are not accepted after a certain age.
- Mix tasks to help with displaying and removing ConfigDB entries. See `mix pleroma.config`.
- OAuth form improvements: users are remembered by their cookie, the CSS is overridable by the admin, and the style has been improved.
- OAuth improvements and fixes: more secure session-based authentication (by token that could be revoked anytime), ability to revoke belonging OAuth token from any client etc.
- Ability to set ActivityPub aliases for follower migration.
- Configurable background job limits for RichMedia (link previews) and MediaProxyWarmingPolicy


<details>
<summary>API Changes</summary>
@@ -30,13 +43,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Pleroma API: Add `idempotency_key` to the chat message entity that can be used for optimistic message sending.
- Pleroma API: (`GET /api/v1/pleroma/federation_status`) Add a way to get a list of unreachable instances.
- Mastodon API: User and conversation mutes can now auto-expire if `expires_in` parameter was given while adding the mute.
- Admin API: An endpoint to manage frontends

- Admin API: An endpoint to manage frontends.
- Streaming API: Add follow relationships updates.
- WebPush: Introduce `pleroma:chat_mention` and `pleroma:emoji_reaction` notification types
</details>

### Fixed

- Users with `is_discoverable` field set to false (default value) will appear in in-service search results but be hidden from external services (search bots etc.).
- Streaming API: Posts and notifications are not dropped, when CLI task is executing.
- Creating incorrect IPv4 address-style HTTP links when encountering certain numbers.
- Reblog API Endpoint: Do not set visibility parameter to public by default and let CommonAPI to infer it from status, so a user can reblog their private status without explicitly setting reblog visibility to private.
- Tag URLs in statuses are now absolute

<details>
<summary>API Changes</summary>
@@ -46,23 +64,42 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased (Patch)


## [2.2.2] - 2020-01-18

### Fixed

- StealEmojiPolicy creates dir for emojis, if it doesn't exist.
- Updated `elixir_make` to a non-retired version

### Upgrade notes

1. Restart Pleroma

## [2.2.1] - 2020-12-22

### Changed
- Updated Pleroma FE

### Fixed

- Config generation: rename `Pleroma.Upload.Filter.ExifTool` to `Pleroma.Upload.Filter.Exiftool`.
- Search: RUM index search speed has been fixed.
- S3 Uploads with Elixir 1.11.
- Emoji Reaction activity filtering from blocked and muted accounts.
- Mix task pleroma.user delete_activities for source installations.
- Fix ability to update Pleroma Chat push notifications with PUT /api/v1/push/subscription and alert type pleroma:chat_mention
- Search: RUM index search speed has been fixed.
- Rich Media Previews sometimes showed the wrong preview due to a bug following redirects.
- Fixes for the autolinker.
- Forwarded reports duplication from Pleroma instances.
- Emoji Reaction activity filtering from blocked and muted accounts.

<details>
<summary>API</summary>
- Statuses were not displayed for Mastodon forwarded reports.
- <details>
<summary>API</summary>
- Statuses were not displayed for Mastodon forwarded reports.
</details>

</details>
### Upgrade notes

1. Restart Pleroma

## [2.2.0] - 2020-11-12

@@ -100,7 +137,7 @@ switched to a new configuration mechanism, however it was not officially removed

- Media preview proxy (requires `ffmpeg` and `ImageMagick` to be installed and media proxy to be enabled; see `:media_preview_proxy` config for more details).
- Mix tasks for controlling user account confirmation status in bulk (`mix pleroma.user confirm_all` and `mix pleroma.user unconfirm_all`)
- Mix task for sending confirmation emails to all unconfirmed users (`mix pleroma.email send_confirmation_mails`)
- Mix task for sending confirmation emails to all unconfirmed users (`mix pleroma.email resend_confirmation_emails`)
- Mix task option for force-unfollowing relays
- App metrics: ability to restrict access to specified IP whitelist.



+ 1
- 1
COPYING View File

@@ -1,4 +1,4 @@
Unless otherwise stated this repository is copyright © 2017-2020
Unless otherwise stated this repository is copyright © 2017-2021
Pleroma Authors <https://pleroma.social/>, and is distributed under
The GNU Affero General Public License Version 3, you should have received a
copy of the license file as AGPL-3.


+ 3
- 3
benchmarks/load_testing/users.ex View File

@@ -55,7 +55,7 @@ defmodule Pleroma.LoadTesting.Users do
name: "Test テスト User #{i}",
email: "user#{i}@example.com",
nickname: "nick#{i}",
password_hash: Pbkdf2.hash_pwd_salt("test"),
password_hash: Pleroma.Password.Pbkdf2.hash_pwd_salt("test"),
bio: "Tester Number #{i}",
local: !remote
}
@@ -109,8 +109,8 @@ defmodule Pleroma.LoadTesting.Users do
end

def make_friends(%User{} = main_user, %User{} = user) do
{:ok, _} = User.follow(main_user, user)
{:ok, _} = User.follow(user, main_user)
{:ok, _, _} = User.follow(main_user, user)
{:ok, _, _} = User.follow(user, main_user)
end

@spec get_users(User.t(), keyword()) :: [User.t()]


+ 1
- 1
benchmarks/mix/tasks/pleroma/benchmarks/timelines.ex View File

@@ -50,7 +50,7 @@ defmodule Mix.Tasks.Pleroma.Benchmarks.Timelines do
)

users
|> Enum.each(fn {:ok, follower} -> Pleroma.User.follow(follower, user) end)
|> Enum.each(fn {:ok, follower, user} -> Pleroma.User.follow(follower, user) end)

Benchee.run(
%{


+ 22
- 17
config/config.exs View File

@@ -47,7 +47,6 @@ use Mix.Config
config :pleroma, ecto_repos: [Pleroma.Repo]

config :pleroma, Pleroma.Repo,
types: Pleroma.PostgresTypes,
telemetry_event: [Pleroma.Repo.Instrumenter],
migration_lock: nil

@@ -64,23 +63,24 @@ config :pleroma, Pleroma.Upload,
filters: [Pleroma.Upload.Filter.Dedupe],
link_name: false,
proxy_remote: false,
proxy_opts: [
redirect_on_failure: false,
max_body_length: 25 * 1_048_576,
http: [
follow_redirect: true,
pool: :upload
]
],
filename_display_max_length: 30,
default_description: nil
default_description: nil,
base_url: nil

config :pleroma, Pleroma.Uploaders.Local, uploads: "uploads"

config :pleroma, Pleroma.Uploaders.S3,
bucket: nil,
streaming_enabled: true,
public_endpoint: "https://s3.amazonaws.com"
bucket_namespace: nil,
truncated_namespace: nil,
streaming_enabled: true

config :ex_aws, :s3,
# host: "s3.wasabisys.com", # required if not Amazon AWS
access_key_id: nil,
secret_access_key: nil,
# region: "us-east-1", # may be required for Amazon AWS
scheme: "https://"

config :pleroma, :emoji,
shortcode_globs: ["/emoji/custom/**/*.png"],
@@ -306,7 +306,7 @@ config :pleroma, :frontend_configurations,
hideSitename: false,
hideUserStats: false,
loginMethod: "password",
logo: "/static/logo.png",
logo: "/static/logo.svg",
logoMargin: ".1em",
logoMask: true,
minimalScopesMode: false,
@@ -343,8 +343,8 @@ config :pleroma, :assets,
config :pleroma, :manifest,
icons: [
%{
src: "/static/logo.png",
type: "image/png"
src: "/static/logo.svg",
type: "image/svg+xml"
}
],
theme_color: "#282c37",
@@ -551,7 +551,7 @@ config :pleroma, Oban,
scheduled_activities: 10,
background: 5,
remote_fetcher: 2,
attachments_cleanup: 5,
attachments_cleanup: 1,
new_users_digest: 1,
mute_expire: 5
],
@@ -648,7 +648,7 @@ config :pleroma, :email_notifications,
}

config :pleroma, :oauth2,
token_expires_in: 600,
token_expires_in: 3600 * 24 * 365 * 100,
issue_new_refresh_token: true,
clean_expired_tokens: false

@@ -832,6 +832,11 @@ config :pleroma, Pleroma.User.Backup,
limit_days: 7,
dir: nil

config :pleroma, ConcurrentLimiter, [
{Pleroma.Web.RichMedia.Helpers, [max_running: 5, max_waiting: 5]},
{Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy, [max_running: 5, max_waiting: 5]}
]

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"

+ 71
- 138
config/description.exs View File

@@ -101,74 +101,10 @@ config :pleroma, :config_description, [
%{
key: :proxy_remote,
type: :boolean,
description:
"If enabled, requests to media stored using a remote uploader will be proxied instead of being redirected"
},
%{
key: :proxy_opts,
label: "Proxy Options",
type: :keyword,
description: "Options for Pleroma.ReverseProxy",
suggestions: [
redirect_on_failure: false,
max_body_length: 25 * 1_048_576,
http: [
follow_redirect: true,
pool: :media
]
],
children: [
%{
key: :redirect_on_failure,
type: :boolean,
description:
"Redirects the client to the real remote URL if there's any HTTP errors. " <>
"Any error during body processing will not be redirected as the response is chunked."
},
%{
key: :max_body_length,
type: :integer,
description:
"Limits the content length to be approximately the " <>
"specified length. It is validated with the `content-length` header and also verified when proxying."
},
%{
key: :http,
label: "HTTP",
type: :keyword,
description: "HTTP options",
children: [
%{
key: :adapter,
type: :keyword,
description: "Adapter specific options",
children: [
%{
key: :ssl_options,
type: :keyword,
label: "SSL Options",
description: "SSL options for HTTP adapter",
children: [
%{
key: :versions,
type: {:list, :atom},
description: "List of TLS versions to use",
suggestions: [:tlsv1, ":tlsv1.1", ":tlsv1.2"]
}
]
}
]
},
%{
key: :proxy_url,
label: "Proxy URL",
type: [:string, :tuple],
description: "Proxy URL",
suggestions: ["127.0.0.1:8123", {:socks5, :localhost, 9050}]
}
]
}
]
description: """
Proxy requests to the remote uploader.\n
Useful if media upload endpoint is not internet accessible.
"""
},
%{
key: :filename_display_max_length,
@@ -214,17 +150,11 @@ config :pleroma, :config_description, [
suggestions: ["pleroma"]
},
%{
key: :public_endpoint,
type: :string,
description: "S3 endpoint",
suggestions: ["https://s3.amazonaws.com"]
},
%{
key: :truncated_namespace,
type: :string,
description:
"If you use S3 compatible service such as Digital Ocean Spaces or CDN, set folder name or \"\" etc." <>
" For example, when using CDN to S3 virtual host format, set \"\". At this time, write CNAME to CDN in public_endpoint."
" For example, when using CDN to S3 virtual host format, set \"\". At this time, write CNAME to CDN in Upload base_url."
},
%{
key: :streaming_enabled,
@@ -1254,7 +1184,7 @@ config :pleroma, :config_description, [
hideSitename: false,
hideUserStats: false,
loginMethod: "password",
logo: "/static/logo.png",
logo: "/static/logo.svg",
logoMargin: ".1em",
logoMask: true,
minimalScopesMode: false,
@@ -1340,7 +1270,7 @@ config :pleroma, :config_description, [
key: :logo,
type: {:string, :image},
description: "URL of the logo, defaults to Pleroma's logo",
suggestions: ["/static/logo.png"]
suggestions: ["/static/logo.svg"]
},
%{
key: :logoMargin,
@@ -1550,7 +1480,7 @@ config :pleroma, :config_description, [
%{
key: :enabled,
type: :boolean,
description: "Enables proxying of remote media to the instance's proxy"
description: "Enables proxying of remote media via the instance's proxy"
},
%{
key: :base_url,
@@ -1587,80 +1517,41 @@ config :pleroma, :config_description, [
},
%{
key: :proxy_opts,
label: "Proxy Options",
label: "Advanced MediaProxy Options",
type: :keyword,
description: "Options for Pleroma.ReverseProxy",
description: "Internal Pleroma.ReverseProxy settings",
suggestions: [
redirect_on_failure: false,
max_body_length: 25 * 1_048_576,
max_read_duration: 30_000,
http: [
follow_redirect: true,
pool: :media
]
max_read_duration: 30_000
],
children: [
%{
key: :redirect_on_failure,
type: :boolean,
description:
"Redirects the client to the real remote URL if there's any HTTP errors. " <>
"Any error during body processing will not be redirected as the response is chunked."
description: """
Redirects the client to the origin server upon encountering HTTP errors.\n
Note that files larger than Max Body Length will trigger an error. (e.g., Peertube videos)\n\n
**WARNING:** This setting will allow larger files to be accessed, but exposes the\n
IP addresses of your users to the other servers, bypassing the MediaProxy.
"""
},
%{
key: :max_body_length,
type: :integer,
description:
"Limits the content length to be approximately the " <>
"specified length. It is validated with the `content-length` header and also verified when proxying."
description: "Maximum file size allowed through the Pleroma MediaProxy cache."
},
%{
key: :max_read_duration,
type: :integer,
description: "Timeout (in milliseconds) of GET request to remote URI."
},
%{
key: :http,
label: "HTTP",
type: :keyword,
description: "HTTP options",
children: [
%{
key: :adapter,
type: :keyword,
description: "Adapter specific options",
children: [
%{
key: :ssl_options,
type: :keyword,
label: "SSL Options",
description: "SSL options for HTTP adapter",
children: [
%{
key: :versions,
type: {:list, :atom},
description: "List of TLS version to use",
suggestions: [:tlsv1, ":tlsv1.1", ":tlsv1.2"]
}
]
}
]
},
%{
key: :proxy_url,
label: "Proxy URL",
type: [:string, :tuple],
description: "Proxy URL",
suggestions: ["127.0.0.1:8123", {:socks5, :localhost, 9050}]
}
]
description: "Timeout (in milliseconds) of GET request to the remote URI."
}
]
},
%{
key: :whitelist,
type: {:list, :string},
description: "List of hosts with scheme to bypass the mediaproxy",
description: "List of hosts with scheme to bypass the MediaProxy",
suggestions: ["http://example.com"]
}
]
@@ -1953,14 +1844,8 @@ config :pleroma, :config_description, [
group: :pleroma,
key: Oban,
type: :group,
description: """
[Oban](https://github.com/sorentwo/oban) asynchronous job processor configuration.

Note: if you are running PostgreSQL in [`silent_mode`](https://postgresqlco.nf/en/doc/param/silent_mode?version=9.1),
it's advised to set [`log_destination`](https://postgresqlco.nf/en/doc/param/log_destination?version=9.1) to `syslog`,
otherwise `postmaster.log` file may grow because of "you don't own a lock of type ShareLock" warnings
(see https://github.com/sorentwo/oban/issues/52).
""",
description:
"[Oban](https://github.com/sorentwo/oban) asynchronous job processor configuration.",
children: [
%{
key: :log,
@@ -2540,7 +2425,7 @@ config :pleroma, :config_description, [
key: :token_expires_in,
type: :integer,
description: "The lifetime in seconds of the access token",
suggestions: [600]
suggestions: [2_592_000]
},
%{
key: :issue_new_refresh_token,
@@ -3445,5 +3330,53 @@ config :pleroma, :config_description, [
suggestions: [:text, :protobuf]
}
]
},
%{
group: :pleroma,
key: ConcurrentLimiter,
type: :group,
description: "Limits configuration for background tasks.",
children: [
%{
key: Pleroma.Web.RichMedia.Helpers,
type: :keyword,
description: "Concurrent limits configuration for getting RichMedia for activities.",
suggestions: [max_running: 5, max_waiting: 5],
children: [
%{
key: :max_running,
type: :integer,
description: "Max running concurrently jobs.",
suggestion: [5]
},
%{
key: :max_waiting,
type: :integer,
description: "Max waiting jobs.",
suggestion: [5]
}
]
},
%{
key: Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy,
type: :keyword,
description: "Concurrent limits configuration for MediaProxyWarmingPolicy.",
suggestions: [max_running: 5, max_waiting: 5],
children: [
%{
key: :max_running,
type: :integer,
description: "Max running concurrently jobs.",
suggestion: [5]
},
%{
key: :max_waiting,
type: :integer,
description: "Max waiting jobs.",
suggestion: [5]
}
]
}
]
}
]

+ 2
- 0
config/emoji.txt View File

@@ -1,2 +1,4 @@
firefox, /emoji/Firefox.gif, Gif,Fun
blank, /emoji/blank.png, Fun
dinosaur, /emoji/dino walking.gif, Gif
external_emoji, https://example.com/emoji.png

+ 19
- 7
config/test.exs View File

@@ -47,10 +47,13 @@ config :pleroma, Pleroma.Repo,
password: "postgres",
database: "pleroma_test",
hostname: System.get_env("DB_HOST") || "localhost",
pool: Ecto.Adapters.SQL.Sandbox
pool: Ecto.Adapters.SQL.Sandbox,
pool_size: 50

config :pleroma, :dangerzone, override_repo_pool_size: true

# Reduce hash rounds for testing
config :pbkdf2_elixir, rounds: 1
config :pleroma, :password, iterations: 1

config :tesla, adapter: Tesla.Mock

@@ -112,15 +115,24 @@ config :pleroma, Pleroma.Web.Plugs.RemoteIp, enabled: false

config :pleroma, Pleroma.Web.ApiSpec.CastAndValidate, strict: true

config :pleroma, Pleroma.Uploaders.S3,
bucket: nil,
streaming_enabled: true,
public_endpoint: nil

config :tzdata, :autoupdate, :disabled

config :pleroma, :mrf, policies: []

config :pleroma, :pipeline,
object_validator: Pleroma.Web.ActivityPub.ObjectValidatorMock,
mrf: Pleroma.Web.ActivityPub.MRFMock,
activity_pub: Pleroma.Web.ActivityPub.ActivityPubMock,
side_effects: Pleroma.Web.ActivityPub.SideEffectsMock,
federator: Pleroma.Web.FederatorMock,
config: Pleroma.ConfigMock

config :pleroma, :cachex, provider: Pleroma.CachexMock

config :pleroma, :side_effects,
ap_streamer: Pleroma.Web.ActivityPub.ActivityPubMock,
logger: Pleroma.LoggerMock

if File.exists?("./config/test.secret.exs") do
import_config "test.secret.exs"
else


+ 109
- 1
docs/administration/CLI_tasks/config.md View File

@@ -32,7 +32,7 @@
config :pleroma, configurable_from_database: false
```

To delete transfered settings from database optional flag `-d` can be used. `<env>` is `prod` by default.
To delete transferred settings from database optional flag `-d` can be used. `<env>` is `prod` by default.

=== "OTP"
```sh
@@ -43,3 +43,111 @@ To delete transfered settings from database optional flag `-d` can be used. `<en
```sh
mix pleroma.config migrate_from_db [--env=<env>] [-d]
```

## Dump all of the config settings defined in the database

=== "OTP"

```sh
./bin/pleroma_ctl config dump
```

=== "From Source"

```sh
mix pleroma.config dump
```

## List individual configuration groups in the database

=== "OTP"

```sh
./bin/pleroma_ctl config groups
```

=== "From Source"

```sh
mix pleroma.config groups
```

## Dump the saved configuration values for a specific group or key

e.g., this shows all the settings under `config :pleroma`

=== "OTP"

```sh
./bin/pleroma_ctl config dump pleroma
```

=== "From Source"

```sh
mix pleroma.config dump pleroma
```

To get values under a specific key:

e.g., this shows all the settings under `config :pleroma, :instance`

=== "OTP"

```sh
./bin/pleroma_ctl config dump pleroma instance
```

=== "From Source"

```sh
mix pleroma.config dump pleroma instance
```

## Delete the saved configuration values for a specific group or key

e.g., this deletes all the settings under `config :tesla`

=== "OTP"

```sh
./bin/pleroma_ctl config delete [--force] tesla
```

=== "From Source"

```sh
mix pleroma.config delete [--force] tesla
```

To delete values under a specific key:

e.g., this deletes all the settings under `config :phoenix, :stacktrace_depth`

=== "OTP"

```sh
./bin/pleroma_ctl config delete [--force] phoenix stacktrace_depth
```

=== "From Source"

```sh
mix pleroma.config delete [--force] phoenix stacktrace_depth
```

## Remove all settings from the database

This forcibly removes all saved values in the database.

=== "OTP"

```sh
./bin/pleroma_ctl config [--force] reset
```

=== "From Source"

```sh
mix pleroma.config [--force] reset
```

+ 3
- 4
docs/administration/CLI_tasks/email.md View File

@@ -16,8 +16,7 @@
mix pleroma.email test [--to <destination email address>]
```


Example:
Example:

=== "OTP"

@@ -36,11 +35,11 @@ Example:
=== "OTP"

```sh
./bin/pleroma_ctl email send_confirmation_mails
./bin/pleroma_ctl email resend_confirmation_emails
```

=== "From Source"

```sh
mix pleroma.email send_confirmation_mails
mix pleroma.email resend_confirmation_emails
```

+ 2
- 2
docs/administration/CLI_tasks/user.md View File

@@ -264,13 +264,13 @@
=== "OTP"

```sh
./bin/pleroma_ctl user toggle_confirmed <nickname>
./bin/pleroma_ctl user confirm <nickname>
```

=== "From Source"

```sh
mix pleroma.user toggle_confirmed <nickname>
mix pleroma.user confirm <nickname>
```

## Set confirmation status for all regular active users


+ 13
- 4
docs/configuration/cheatsheet.md View File

@@ -549,7 +549,7 @@ the source code is here: [kocaptcha](https://github.com/koto-bank/kocaptcha). Th
* `uploader`: Which one of the [uploaders](#uploaders) to use.
* `filters`: List of [upload filters](#upload-filters) to use.
* `link_name`: When enabled Pleroma will add a `name` parameter to the url of the upload, for example `https://instance.tld/media/corndog.png?name=corndog.png`. This is needed to provide the correct filename in Content-Disposition headers when using filters like `Pleroma.Upload.Filter.Dedupe`
* `base_url`: The base URL to access a user-uploaded file. Useful when you want to proxy the media files via another host.
* `base_url`: The base URL to access a user-uploaded file. Useful when you want to host the media files via another domain or are using a 3rd party S3 provider.
* `proxy_remote`: If you're using a remote uploader, Pleroma will proxy media requests instead of redirecting to it.
* `proxy_opts`: Proxy options, see `Pleroma.ReverseProxy` documentation.
* `filename_display_max_length`: Set max length of a filename to display. 0 = no limit. Default: 30.
@@ -570,10 +570,7 @@ Don't forget to configure [Ex AWS S3](#ex-aws-s3-settings)

* `bucket`: S3 bucket name.
* `bucket_namespace`: S3 bucket namespace.
* `public_endpoint`: S3 endpoint that the user finally accesses(ex. "https://s3.dualstack.ap-northeast-1.amazonaws.com")
* `truncated_namespace`: If you use S3 compatible service such as Digital Ocean Spaces or CDN, set folder name or "" etc.
For example, when using CDN to S3 virtual host format, set "".
At this time, write CNAME to CDN in public_endpoint.
* `streaming_enabled`: Enable streaming uploads, when enabled the file will be sent to the server in chunks as it's being read. This may be unsupported by some providers, try disabling this if you have upload problems.

#### Ex AWS S3 settings
@@ -1113,3 +1110,15 @@ Settings to enable and configure expiration for ephemeral activities

* `:enabled` - enables ephemeral activities creation
* `:min_lifetime` - minimum lifetime for ephemeral activities (in seconds). Default: 10 minutes.

## ConcurrentLimiter

Settings to restrict concurrently running jobs. Jobs which can be configured:

* `Pleroma.Web.RichMedia.Helpers` - generating link previews of URLs in activities
* `Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy` - warming remote media cache via MediaProxyWarmingPolicy

Each job has these settings:

* `:max_running` - max concurrently runnings jobs
* `:max_waiting` - max waiting jobs

+ 50
- 48
docs/configuration/howto_database_config.md View File

@@ -5,50 +5,37 @@ The configuration of Pleroma has traditionally been managed with a config file,

## Migration to database config

1. Run the mix task to migrate to the database. You'll receive some debugging output and a few messages informing you of what happened.
1. Run the mix task to migrate to the database.

**Source:**
```
$ mix pleroma.config migrate_to_db
```
or
**OTP:**
*Note: OTP users need Pleroma to be running for `pleroma_ctl` commands to work*
```
$ ./bin/pleroma_ctl config migrate_to_db
```

```
10:04:34.155 [debug] QUERY OK source="config" db=1.6ms decode=2.0ms queue=33.5ms idle=0.0ms
SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 []
Migrating settings from file: /home/pleroma/config/dev.secret.exs
10:04:34.240 [debug] QUERY OK db=4.5ms queue=0.3ms idle=92.2ms
TRUNCATE config; []
10:04:34.244 [debug] QUERY OK db=2.8ms queue=0.3ms idle=97.2ms
ALTER SEQUENCE config_id_seq RESTART; []
10:04:34.256 [debug] QUERY OK source="config" db=0.8ms queue=1.4ms idle=109.8ms
SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 WHERE ((c0."group" = $1) AND (c0."key" = $2)) [":pleroma", ":instance"]
10:04:34.292 [debug] QUERY OK db=2.6ms queue=1.7ms idle=137.7ms
INSERT INTO "config" ("group","key","value","inserted_at","updated_at") VALUES ($1,$2,$3,$4,$5) RETURNING "id" [":pleroma", ":instance", <<131, 108, 0, 0, 0, 1, 104, 2, 100, 0, 4, 110, 97, 109, 101, 109, 0, 0, 0, 7, 66, 108, 101, 114, 111, 109, 97, 106>>, ~N[2020-07-12 15:04:34], ~N[2020-07-12 15:04:34]]

Settings for key instance migrated.
Settings for group :pleroma migrated.
```

2. It is recommended to backup your config file now.

```
cp config/dev.secret.exs config/dev.secret.exs.orig
```

3. Edit your Pleroma config to enable database configuration:

```
@@ -76,17 +63,17 @@ The configuration of Pleroma has traditionally been managed with a config file,

config :pleroma, Pleroma.Web.Endpoint,
url: [host: "cool.pleroma.site", scheme: "https", port: 443]
config :pleroma, Pleroma.Repo,
adapter: Ecto.Adapters.Postgres,
username: "pleroma",
password: "MySecretPassword",
database: "pleroma_prod",
hostname: "localhost"
config :pleroma, configurable_from_database: true
```
5. Restart your instance and you can now access the Settings tab in AdminFE.


@@ -95,15 +82,15 @@ The configuration of Pleroma has traditionally been managed with a config file,
1. Run the mix task to migrate back from the database. You'll receive some debugging output and a few messages informing you of what happened.

**Source:**
```
$ mix pleroma.config migrate_from_db
```
or
**OTP:**
```
$ ./bin/pleroma_ctl config migrate_from_db
```
@@ -111,7 +98,7 @@ The configuration of Pleroma has traditionally been managed with a config file,
```
10:26:30.593 [debug] QUERY OK source="config" db=9.8ms decode=1.2ms queue=26.0ms idle=0.0ms
SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 []
10:26:30.659 [debug] QUERY OK source="config" db=1.1ms idle=80.7ms
SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_at" FROM "config" AS c0 []
Database configuration settings have been saved to config/dev.exported_from_db.secret.exs
@@ -124,30 +111,45 @@ The configuration of Pleroma has traditionally been managed with a config file,
## Debugging

### Clearing database config
You can clear the database config by truncating the `config` table in the database. e.g.,
You can clear the database config with the following command:

**Source:**

```
psql -d pleroma_dev
pleroma_dev=# TRUNCATE config;
TRUNCATE TABLE
```
```
$ mix pleroma.config reset
```

or

**OTP:**

```
$ ./bin/pleroma_ctl config reset
```

Additionally, every time you migrate the configuration to the database the config table is automatically truncated to ensure a clean migration.

### Manually removing a setting
If you encounter a situation where the server cannot run properly because of an invalid setting in the database and this is preventing you from accessing AdminFE, you can manually remove the offending setting if you know which one it is.

e.g., here is an example showing a minimal configuration in the database. Only the `config :pleroma, :instance` settings are in the table:

```
psql -d pleroma_dev
pleroma_dev=# select * from config;
id | key | value | inserted_at | updated_at | group
----+-----------+------------------------------------------------------------+---------------------+---------------------+----------
1 | :instance | \x836c0000000168026400046e616d656d00000007426c65726f6d616a | 2020-07-12 15:33:29 | 2020-07-12 15:33:29 | :pleroma
(1 row)
pleroma_dev=# delete from config where key = ':instance' and group = ':pleroma';
DELETE 1
```
e.g., here is an example showing a the removal of the `config :pleroma, :instance` settings:

**Source:**

```
$ mix pleroma.config delete pleroma instance
Are you sure you want to continue? [n] y
config :pleroma, :instance deleted from the ConfigDB.
```

or

**OTP:**

```
$ ./bin/pleroma_ctl config delete pleroma instance
Are you sure you want to continue? [n] y
config :pleroma, :instance deleted from the ConfigDB.
```

Now the `config :pleroma, :instance` settings have been removed from the database.

+ 23
- 0
docs/configuration/mrf.md View File

@@ -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]
}
]
}
```

+ 22
- 5
docs/configuration/postgresql.md View File

@@ -1,10 +1,28 @@
# Optimizing your PostgreSQL performance
# Optimizing PostgreSQL performance

Pleroma performance depends to a large extent on good database performance. The default PostgreSQL settings are mostly fine, but often you can get better performance by changing a few settings.
Pleroma performance is largely dependent on performance of the underlying database. Better performance can be achieved by adjusting a few settings.

You can use [PGTune](https://pgtune.leopard.in.ua) to get recommendations for your setup. If you do, set the "Number of Connections" field to 20, as Pleroma will only use 10 concurrent connections anyway. If you don't, it will give you advice that might even hurt your performance.
## PGTune

We also recommend not using the "Network Storage" option.
[PgTune](https://pgtune.leopard.in.ua) can be used to get recommended settings. Be sure to set "Number of Connections" to 20, otherwise it might produce settings hurtful to database performance. It is also recommended to not use "Network Storage" option.

## Disable generic query plans

When PostgreSQL receives a query, it decides on a strategy for searching the requested data, this is called a query plan. The query planner has two modes: generic and custom. Generic makes a plan for all queries of the same shape, ignoring the parameters, which is then cached and reused. Custom, on the contrary, generates a unique query plan based on query parameters.

By default PostgreSQL has an algorithm to decide which mode is more efficient for particular query, however this algorithm has been observed to be wrong on some of the queries Pleroma sends, leading to serious performance loss. Therefore, it is recommended to disable generic mode.


Pleroma already avoids generic query plans by default, however the method it uses is not the most efficient because it needs to be compatible with all supported PostgreSQL versions. For PostgreSQL 12 and higher additional performance can be gained by adding the following to Pleroma configuration:
```elixir
config :pleroma, Pleroma.Repo,
prepare: :named,
parameters: [
plan_cache_mode: "force_custom_plan"
]
```

A more detailed explaination of the issue can be found at <https://blog.soykaf.com/post/postgresql-elixir-troubles/>.

## Example configurations

@@ -28,4 +46,3 @@ max_worker_processes = 2
max_parallel_workers_per_gather = 1
max_parallel_workers = 2
```


+ 5
- 0
docs/configuration/static_dir.md View File

@@ -88,3 +88,8 @@ config :pleroma, :frontend_configurations,
Note the extra `static` folder for the terms-of-service.html

Terms of Service will be shown to all users on the registration page. It's the best place where to write down the rules for your instance. You can modify the rules by adding and changing `$static_dir/static/terms-of-service.html`.

## Styling rendered pages

To overwrite the CSS stylesheet of the OAuth form and other static pages, you can upload your own CSS file to `instance/static/static.css`. This will completely replace the CSS used by those pages, so it might be a good idea to copy the one from `priv/static/instance/static.css` and make your changes.

docs/API/admin_api.md → docs/development/API/admin_api.md View File

@@ -1123,6 +1123,7 @@ Loads json generated from `config/descriptions.exs`.
```json
[
{
"id": 1234,
"data": {
"actor": {
"id": 1,

docs/API/chats.md → docs/development/API/chats.md View File


docs/API/differences_in_mastoapi_responses.md → docs/development/API/differences_in_mastoapi_responses.md View File

@@ -4,7 +4,7 @@ A Pleroma instance can be identified by "<Mastodon version> (compatible; Pleroma

## 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
Pleroma uses 128-bit ids as opposed to Mastodon's 64 bits. However, just like Mastodon's ids, they are lexically sortable strings

## Timelines

@@ -26,8 +26,8 @@ Has these additional fields under the `pleroma` object:
- `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 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`
- `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.
@@ -170,9 +170,9 @@ Returns on success: 200 OK `{}`

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 entitiy would still be rendered back. This could be useful for previewing rich text/custom emoji, for example.
- `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 for post visibility are not affected by this and will still apply.
- `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`.
@@ -206,6 +206,7 @@ Additional parameters can be added to the JSON body/Form data:
- `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.
@@ -279,10 +280,27 @@ Has these additional fields under the `pleroma` object:

## 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.

docs/API/pleroma_api.md → docs/development/API/pleroma_api.md View File

@@ -580,14 +580,14 @@ Emoji reactions work a lot like favourites do. They make it possible to react to
### React to a post with a unicode emoji
* Method: `PUT`
* Authentication: required
* Params: `emoji`: A single character unicode emoji
* 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 single character unicode emoji
* Params: `emoji`: A unicode RGI emoji or a regional indicator
* Response: JSON, the status.

## `GET /api/v1/pleroma/statuses/:id/reactions`

docs/API/prometheus.md → docs/development/API/prometheus.md View File


docs/ap_extensions.md → docs/development/ap_extensions.md View File


docs/dev.md → docs/development/authentication_authorization.md View File

@@ -1,5 +1,3 @@
This document contains notes and guidelines for Pleroma developers.

# Authentication & Authorization

## OAuth token-based authentication & authorization
@@ -14,33 +12,10 @@ This document contains notes and guidelines for Pleroma developers.

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.

## [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization)
## Non-OAuth authentication

* With HTTP Basic 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). `Pleroma.Web.Plugs.AuthenticationPlug` and `Pleroma.Web.Plugs.LegacyAuthenticationPlug` both call `Pleroma.Web.Plugs.OAuthScopesPlug.skip_plug(conn)` when password is provided.
* 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]
}
]
}
```
See `Authentication` section of [the configuration cheatsheet](../configuration/cheatsheet.md#authentication).

+ 1
- 0
docs/development/index.md View File

@@ -0,0 +1 @@
This section contains notes and guidelines for developers.

+ 70
- 0
docs/development/setting_up_pleroma_dev.md View File

@@ -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://<host>:<port>` (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).

+ 1
- 1
docs/installation/alpine_linux_en.md View File

@@ -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


+ 1
- 1
docs/installation/arch_linux_en.md View File

@@ -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


+ 1
- 1
docs/installation/debian_based_en.md View File

@@ -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


+ 1
- 1
docs/installation/debian_based_jp.md View File

@@ -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


+ 1
- 1
docs/installation/freebsd_en.md View File

@@ -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


+ 1
- 1
docs/installation/netbsd_en.md View File

@@ -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`



+ 1
- 1
docs/installation/openbsd_en.md View File

@@ -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


+ 1
- 1
docs/installation/openbsd_fi.md View File

@@ -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


+ 2
- 11
docs/installation/otp_en.md View File

@@ -89,6 +89,8 @@ RUM indexes are an alternative indexing scheme that is not included in PostgreSQ
#### (Optional) Performance configuration
It is encouraged to check [Optimizing your PostgreSQL performance](../configuration/postgresql.md) document, for tips on PostgreSQL tuning.

Restart PostgreSQL to apply configuration changes:

=== "Alpine"
```
rc-service postgresql restart
@@ -99,17 +101,6 @@ It is encouraged to check [Optimizing your PostgreSQL performance](../configurat
systemctl restart postgresql
```

If you are using PostgreSQL 12 or higher, add this to your Ecto database configuration

```elixir
#
config :pleroma, Pleroma.Repo,
prepare: :named,
parameters: [
plan_cache_mode: "force_custom_plan"
]
```

### Installing Pleroma
```sh
# Create a Pleroma user


+ 13
- 10
installation/download-mastofe-build.sh View File

@@ -1,6 +1,6 @@
#!/bin/sh
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
project_id="74"
project_branch="rebase/glitch-soc"
@@ -9,29 +9,32 @@ static_dir="instance/static"
# project_branch="pleroma"
# static_dir="priv/static"

if [[ ! -d "${static_dir}" ]]
if [ ! -d "${static_dir}" ]
then
echo "Error: ${static_dir} directory is missing, are you sure you are running this script at the root of pleroma’s repository?"
exit 1
fi

last_modified="$(curl -s -I 'https://git.pleroma.social/api/v4/projects/'${project_id}'/jobs/artifacts/'${project_branch}'/download?job=build' | grep '^Last-Modified:' | cut -d: -f2-)"
last_modified="$(curl --fail -s -I 'https://git.pleroma.social/api/v4/projects/'${project_id}'/jobs/artifacts/'${project_branch}'/download?job=build' | grep '^Last-Modified:' | cut -d: -f2-)"

echo "branch:${project_branch}"
echo "Last-Modified:${last_modified}"

artifact="mastofe.zip"

if [[ -e mastofe.timestamp ]] && [[ "${last_modified}" != "" ]]
if [ "${last_modified}x" = "x" ]
then
if [[ "$(cat mastofe.timestamp)" == "${last_modified}" ]]
then
echo "MastoFE is up-to-date, exiting…"
exit 0
fi
echo "ERROR: Couldn't get the modification date of the latest build archive, maybe it expired, exiting..."
exit 1
fi

if [ -e mastofe.timestamp ] && [ "$(cat mastofe.timestamp)" = "${last_modified}" ]
then
echo "MastoFE is up-to-date, exiting..."
exit 0
fi

curl -c - "https://git.pleroma.social/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=build" -o "${artifact}" || exit
curl --fail -c - "https://git.pleroma.social/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=build" -o "${artifact}" || exit

# TODO: Update the emoji as well
rm -fr "${static_dir}/sw.js" "${static_dir}/packs" || exit


+ 0
- 9
lib/jason_types.ex View File

@@ -1,9 +0,0 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

Postgrex.Types.define(
Pleroma.PostgresTypes,
[] ++ Ecto.Adapters.Postgres.extensions(),
json: Jason
)

+ 16
- 9
lib/mix/pleroma.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Pleroma do
@@ -12,7 +12,9 @@ defmodule Mix.Pleroma do
:cachex,
:flake_id,
:swoosh,
:timex
:timex,
:fast_html,
:oban
]
@cachex_children ["object", "user", "scrubber", "web_resp"]
@doc "Common functions to be reused in mix tasks"
@@ -37,12 +39,23 @@ defmodule Mix.Pleroma do

Enum.each(apps, &Application.ensure_all_started/1)

oban_config = [
crontab: [],
repo: Pleroma.Repo,
log: false,
queues: [],
plugins: []
]

children =
[
Pleroma.Repo,
Pleroma.Emoji,
{Pleroma.Config.TransferTask, false},
Pleroma.Web.Endpoint,
{Oban, Pleroma.Config.get(Oban)}
{Oban, oban_config},
{Majic.Pool,
[name: Pleroma.MajicPool, pool_size: Pleroma.Config.get([:majic_pool, :size], 2)]}
] ++
http_children(adapter)

@@ -98,12 +111,6 @@ defmodule Mix.Pleroma do
end
end

def shell_yes?(message) do
if mix_shell?(),
do: Mix.shell().yes?("Continue?"),
else: shell_prompt(message, "Continue?") in ~w(Yn Y y)
end

def shell_info(message) do
if mix_shell?(),
do: Mix.shell().info(message),


+ 1
- 1
lib/mix/tasks/pleroma/app.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.App do


+ 1
- 1
lib/mix/tasks/pleroma/benchmark.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.Benchmark do


+ 281
- 50
lib/mix/tasks/pleroma/config.ex View File

@@ -1,10 +1,11 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.Config do
use Mix.Task

import Ecto.Query
import Mix.Pleroma

alias Pleroma.ConfigDB
@@ -14,26 +15,199 @@ defmodule Mix.Tasks.Pleroma.Config do
@moduledoc File.read!("docs/administration/CLI_tasks/config.md")

def run(["migrate_to_db"]) do
start_pleroma()
migrate_to_db()
check_configdb(fn ->
start_pleroma()
migrate_to_db()
end)
end

def run(["migrate_from_db" | options]) do
check_configdb(fn ->
start_pleroma()

{opts, _} =
OptionParser.parse!(options,
strict: [env: :string, delete: :boolean],
aliases: [d: :delete]
)

migrate_from_db(opts)
end)
end

def run(["dump"]) do
check_configdb(fn ->
start_pleroma()

header = config_header()

settings =
ConfigDB
|> Repo.all()
|> Enum.sort()

unless settings == [] do
shell_info("#{header}")

Enum.each(settings, &dump(&1))
else
shell_error("No settings in ConfigDB.")
end
end)
end

def run(["dump", group, key]) do
check_configdb(fn ->
start_pleroma()

group = maybe_atomize(group)
key = maybe_atomize(key)

group
|> ConfigDB.get_by_group_and_key(key)
|> dump()
end)
end

def run(["dump", group]) do
check_configdb(fn ->
start_pleroma()

group = maybe_atomize(group)

dump_group(group)
end)
end

def run(["groups"]) do
check_configdb(fn ->
start_pleroma()

groups =
ConfigDB
|> distinct([c], true)
|> select([c], c.group)
|> Repo.all()

if length(groups) > 0 do
shell_info("The following configuration groups are set in ConfigDB:\r\n")
groups |> Enum.each(fn x -> shell_info("- #{x}") end)
shell_info("\r\n")
end
end)
end

def run(["reset", "--force"]) do
check_configdb(fn ->
start_pleroma()
truncatedb()
shell_info("The ConfigDB settings have been removed from the database.")
end)
end

def run(["reset"]) do
check_configdb(fn ->
start_pleroma()

shell_info("The following settings will be permanently removed:")

ConfigDB
|> Repo.all()
|> Enum.sort()
|> Enum.each(&dump(&1))

shell_error("\nTHIS CANNOT BE UNDONE!")

if shell_prompt("Are you sure you want to continue?", "n") in ~w(Yn Y y) do
truncatedb()

shell_info("The ConfigDB settings have been removed from the database.")
else
shell_error("No changes made.")
end
end)
end

def run(["delete", "--force", group, key]) do
start_pleroma()

group = maybe_atomize(group)
key = maybe_atomize(key)

with true <- key_exists?(group, key) do
shell_info("The following settings will be removed from ConfigDB:\n")

group
|> ConfigDB.get_by_group_and_key(key)
|> dump()

delete_key(group, key)
else
_ ->
shell_error("No settings in ConfigDB for #{inspect(group)}, #{inspect(key)}. Aborting.")
end
end

def run(["delete", "--force", group]) do
start_pleroma()

{opts, _} =
OptionParser.parse!(options,
strict: [env: :string, delete: :boolean],
aliases: [d: :delete]
)
group = maybe_atomize(group)

migrate_from_db(opts)
with true <- group_exists?(group) do
shell_info("The following settings will be removed from ConfigDB:\n")
dump_group(group)
delete_group(group)
else
_ -> shell_error("No settings in ConfigDB for #{inspect(group)}. Aborting.")
end
end

def run(["delete", group, key]) do
start_pleroma()

group = maybe_atomize(group)
key = maybe_atomize(key)

with true <- key_exists?(group, key) do
shell_info("The following settings will be removed from ConfigDB:\n")

group
|> ConfigDB.get_by_group_and_key(key)
|> dump()

if shell_prompt("Are you sure you want to continue?", "n") in ~w(Yn Y y) do
delete_key(group, key)
else
shell_error("No changes made.")
end
else
_ ->
shell_error("No settings in ConfigDB for #{inspect(group)}, #{inspect(key)}. Aborting.")
end
end

def run(["delete", group]) do
start_pleroma()

group = maybe_atomize(group)

with true <- group_exists?(group) do
shell_info("The following settings will be removed from ConfigDB:\n")
dump_group(group)

if shell_prompt("Are you sure you want to continue?", "n") in ~w(Yn Y y) do
delete_group(group)
else
shell_error("No changes made.")
end
else
_ -> shell_error("No settings in ConfigDB for #{inspect(group)}. Aborting.")
end
end

@spec migrate_to_db(Path.t() | nil) :: any()
def migrate_to_db(file_path \\ nil) do
with true <- Pleroma.Config.get([:configurable_from_database]),
:ok <- Pleroma.Config.DeprecationWarnings.warn() do
with :ok <- Pleroma.Config.DeprecationWarnings.warn() do
config_file =
if file_path do
file_path
@@ -47,16 +221,15 @@ defmodule Mix.Tasks.Pleroma.Config do

do_migrate_to_db(config_file)
else
:error -> deprecation_error()
_ -> migration_error()
_ ->
shell_error("Migration is not allowed until all deprecation warnings have been resolved.")
end
end

defp do_migrate_to_db(config_file) do
if File.exists?(config_file) do
shell_info("Migrating settings from file: #{Path.expand(config_file)}")
Ecto.Adapters.SQL.query!(Repo, "TRUNCATE config;")
Ecto.Adapters.SQL.query!(Repo, "ALTER SEQUENCE config_id_seq RESTART;")
truncatedb()

custom_config =
config_file
@@ -80,52 +253,38 @@ defmodule Mix.Tasks.Pleroma.Config do
shell_info("Settings for key #{key} migrated.")
end)

shell_info("Settings for group :#{group} migrated.")
shell_info("Settings for group #{inspect(group)} migrated.")
end

defp migrate_from_db(opts) do
if Pleroma.Config.get([:configurable_from_database]) do
env = opts[:env] || Pleroma.Config.get(:env)

config_path =
if Pleroma.Config.get(:release) do
:config_path
|> Pleroma.Config.get()
|> Path.dirname()
else
"config"
end
|> Path.join("#{env}.exported_from_db.secret.exs")
env = opts[:env] || Pleroma.Config.get(:env)

file = File.open!(config_path, [:write, :utf8])
config_path =
if Pleroma.Config.get(:release) do
:config_path
|> Pleroma.Config.get()
|> Path.dirname()
else
"config"
end
|> Path.join("#{env}.exported_from_db.secret.exs")

IO.write(file, config_header())
file = File.open!(config_path, [:write, :utf8])

ConfigDB
|> Repo.all()
|> Enum.each(&write_and_delete(&1, file, opts[:delete]))
IO.write(file, config_header())

:ok = File.close(file)
System.cmd("mix", ["format", config_path])
ConfigDB
|> Repo.all()
|> Enum.each(&write_and_delete(&1, file, opts[:delete]))

shell_info(
"Database configuration settings have been exported to config/#{env}.exported_from_db.secret.exs"
)
else
migration_error()
end
end
:ok = File.close(file)
System.cmd("mix", ["format", config_path])

defp migration_error do
shell_error(
"Migration is not allowed in config. You can change this behavior by setting `config :pleroma, configurable_from_database: true`"
shell_info(
"Database configuration settings have been exported to config/#{env}.exported_from_db.secret.exs"
)
end

defp deprecation_error do
shell_error("Migration is not allowed until all deprecation warnings have been resolved.")
end

if Code.ensure_loaded?(Config.Reader) do
defp config_header, do: "import Config\r\n\r\n"
defp read_file(config_file), do: Config.Reader.read_imports!(config_file)
@@ -150,8 +309,80 @@ defmodule Mix.Tasks.Pleroma.Config do

defp delete(config, true) do
{:ok, _} = Repo.delete(config)
shell_info("#{config.key} deleted from DB.")

shell_info(
"config #{inspect(config.group)}, #{inspect(config.key)} was deleted from the ConfigDB."
)
end

defp delete(_config, _), do: :ok

defp dump(%ConfigDB{} = config) do
value = inspect(config.value, limit: :infinity)

shell_info("config #{inspect(config.group)}, #{inspect(config.key)}, #{value}\r\n\r\n")
end

defp dump(_), do: :noop

defp dump_group(group) when is_atom(group) do
group
|> ConfigDB.get_all_by_group()
|> Enum.each(&dump/1)
end

defp group_exists?(group) do
group
|> ConfigDB.get_all_by_group()
|> Enum.any?()
end

defp key_exists?(group, key) do
group
|> ConfigDB.get_by_group_and_key(key)
|> is_nil
|> Kernel.!()
end

defp maybe_atomize(arg) when is_atom(arg), do: arg

defp maybe_atomize(":" <> arg), do: maybe_atomize(arg)

defp maybe_atomize(arg) when is_binary(arg) do
if ConfigDB.module_name?(arg) do
String.to_existing_atom("Elixir." <> arg)
else
String.to_atom(arg)
end
end

defp check_configdb(callback) do
with true <- Pleroma.Config.get([:configurable_from_database]) do
callback.()
else
_ ->
shell_error(
"ConfigDB not enabled. Please check the value of :configurable_from_database in your configuration."
)
end
end

defp delete_key(group, key) do
check_configdb(fn ->
ConfigDB.delete(%{group: group, key: key})
end)
end

defp delete_group(group) do
check_configdb(fn ->
group
|> ConfigDB.get_all_by_group()
|> Enum.each(&ConfigDB.delete/1)
end)
end

defp truncatedb do
Ecto.Adapters.SQL.query!(Repo, "TRUNCATE config;")
Ecto.Adapters.SQL.query!(Repo, "ALTER SEQUENCE config_id_seq RESTART;")
end
end

+ 1
- 1
lib/mix/tasks/pleroma/count_statuses.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.CountStatuses do


+ 10
- 4
lib/mix/tasks/pleroma/database.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.Database do
@@ -48,9 +48,15 @@ defmodule Mix.Tasks.Pleroma.Database do
def run(["update_users_following_followers_counts"]) do
start_pleroma()

User
|> Repo.all()
|> Enum.each(&User.update_follower_count/1)
Repo.transaction(
fn ->
from(u in User, select: u)
|> Repo.stream()
|> Stream.each(&User.update_follower_count/1)
|> Stream.run()
end,
timeout: :infinity
)
end

def run(["prune_objects" | args]) do


+ 1
- 1
lib/mix/tasks/pleroma/digest.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.Digest do


+ 1
- 1
lib/mix/tasks/pleroma/docs.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.Docs do


+ 1
- 1
lib/mix/tasks/pleroma/ecto.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-onl

defmodule Mix.Tasks.Pleroma.Ecto do


+ 1
- 1
lib/mix/tasks/pleroma/ecto/migrate.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-onl

defmodule Mix.Tasks.Pleroma.Ecto.Migrate do


+ 1
- 1
lib/mix/tasks/pleroma/ecto/rollback.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-onl

defmodule Mix.Tasks.Pleroma.Ecto.Rollback do


+ 2
- 2
lib/mix/tasks/pleroma/email.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.Email do
@@ -34,7 +34,7 @@ defmodule Mix.Tasks.Pleroma.Email do
Pleroma.User.Query.build(%{
local: true,
deactivated: false,
confirmation_pending: true,
is_confirmed: false,
invisible: false
})
|> Pleroma.Repo.chunk_stream(500)


+ 1
- 1
lib/mix/tasks/pleroma/emoji.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.Emoji do


+ 1
- 1
lib/mix/tasks/pleroma/frontend.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.Frontend do


+ 13
- 4
lib/mix/tasks/pleroma/instance.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.Instance do
@@ -161,12 +161,21 @@ defmodule Mix.Tasks.Pleroma.Instance do
)
|> Path.expand()

{strip_uploads_message, strip_uploads_default} =
if Pleroma.Utils.command_available?("exiftool") do
{"Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as installed. (y/n)",
"y"}
else
{"Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as not installed, please install it if you answer yes. (y/n)",
"n"}
end

strip_uploads =
get_option(
options,
:strip_uploads,
"Do you want to strip location (GPS) data from uploaded images? (y/n)",
"y"
strip_uploads_message,
strip_uploads_default
) === "y"

anonymize_uploads =
@@ -253,7 +262,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
else
shell_error(
"The task would have overwritten the following files:\n" <>
(Enum.map(paths, &"- #{&1}\n") |> Enum.join("")) <>
(Enum.map(will_overwrite, &"- #{&1}\n") |> Enum.join("")) <>
"Rerun with `--force` to overwrite them."
)
end


+ 1
- 1
lib/mix/tasks/pleroma/notification_settings.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.NotificationSettings do


+ 1
- 1
lib/mix/tasks/pleroma/refresh_counter_cache.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.RefreshCounterCache do


+ 1
- 1
lib/mix/tasks/pleroma/relay.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.Relay do


+ 1
- 1
lib/mix/tasks/pleroma/robots_txt.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.RobotsTxt do


+ 1
- 1
lib/mix/tasks/pleroma/uploads.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.Uploads do


+ 12
- 12
lib/mix/tasks/pleroma/user.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Mix.Tasks.Pleroma.User do
@@ -60,7 +60,7 @@ defmodule Mix.Tasks.Pleroma.User do
- admin: #{if(admin?, do: "true", else: "false")}
""")

proceed? = assume_yes? or shell_yes?("Continue?")
proceed? = assume_yes? or shell_prompt("Continue?", "n") in ~w(Yn Y y)

if proceed? do
start_pleroma()
@@ -74,7 +74,7 @@ defmodule Mix.Tasks.Pleroma.User do
bio: bio
}

changeset = User.register_changeset(%User{}, params, need_confirmation: false)
changeset = User.register_changeset(%User{}, params, is_confirmed: true)
{:ok, _user} = User.register(changeset)

shell_info("User #{nickname} created")
@@ -213,7 +213,7 @@ defmodule Mix.Tasks.Pleroma.User do
user =
case Keyword.get(options, :confirmed) do
nil -> user
value -> set_confirmed(user, value)
value -> set_confirmation(user, value)
end

user =
@@ -345,13 +345,13 @@ defmodule Mix.Tasks.Pleroma.User do
end
end

def run(["toggle_confirmed", nickname]) do
def run(["confirm", nickname]) do
start_pleroma()

with %User{} = user <- User.get_cached_by_nickname(nickname) do
{:ok, user} = User.toggle_confirmation(user)
{:ok, user} = User.confirm(user)

message = if user.confirmation_pending, do: "needs", else: "doesn't need"
message = if !user.is_confirmed, do: "needs", else: "doesn't need"

shell_info("#{nickname} #{message} confirmation.")
else
@@ -373,7 +373,7 @@ defmodule Mix.Tasks.Pleroma.User do
|> Pleroma.Repo.chunk_stream(500, :batches)
|> Stream.each(fn users ->
users
|> Enum.each(fn user -> User.need_confirmation(user, false) end)
|> Enum.each(fn user -> User.set_confirmation(user, true) end)
end)
|> Stream.run()
end
@@ -391,7 +391,7 @@ defmodule Mix.Tasks.Pleroma.User do
|> Pleroma.Repo.chunk_stream(500, :batches)
|> Stream.each(fn users ->
users
|> Enum.each(fn user -> User.need_confirmation(user, true) end)
|> Enum.each(fn user -> User.set_confirmation(user, false) end)
end)
|> Stream.run()
end
@@ -454,10 +454,10 @@ defmodule Mix.Tasks.Pleroma.User do
user
end

defp set_confirmed(user, value) do
{:ok, user} = User.need_confirmation(user, !value)
defp set_confirmation(user, value) do
{:ok, user} = User.set_confirmation(user, value)

shell_info("Confirmation pending status of #{user.nickname}: #{user.confirmation_pending}")
shell_info("Confirmation status of #{user.nickname}: #{user.is_confirmed}")
user
end
end

+ 1
- 1
lib/phoenix/transports/web_socket/raw.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Phoenix.Transports.WebSocket.Raw do


+ 18
- 3
lib/pleroma/activity.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Activity do
@@ -24,6 +24,8 @@ defmodule Pleroma.Activity do

@primary_key {:id, FlakeId.Ecto.CompatType, autogenerate: true}

@cachex Pleroma.Config.get([:cachex, :provider], Cachex)

schema "activities" do
field(:data, :map)
field(:local, :boolean, default: true)
@@ -194,6 +196,19 @@ defmodule Pleroma.Activity do
end
end

def get_by_id_with_user_actor(id) do
case FlakeId.flake_id?(id) do
true ->
Activity
|> where([a], a.id == ^id)
|> with_preloaded_user_actor()
|> Repo.one()

_ ->
nil
end
end

def get_by_id_with_object(id) do
Activity
|> where(id: ^id)
@@ -259,7 +274,7 @@ defmodule Pleroma.Activity do
defp get_in_reply_to_activity_from_object(_), do: nil

def get_in_reply_to_activity(%Activity{} = activity) do
get_in_reply_to_activity_from_object(Object.normalize(activity))
get_in_reply_to_activity_from_object(Object.normalize(activity, fetch: false))
end

def normalize(obj) when is_map(obj), do: get_by_ap_id_with_object(obj["id"])
@@ -285,7 +300,7 @@ defmodule Pleroma.Activity do

defp purge_web_resp_cache(%Activity{} = activity) do
%{path: path} = URI.parse(activity.data["id"])
Cachex.del(:web_resp_cache, path)
@cachex.del(:web_resp_cache, path)
activity
end



+ 2
- 2
lib/pleroma/activity/ir/topics.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Activity.Ir.Topics do
@@ -8,7 +8,7 @@ defmodule Pleroma.Activity.Ir.Topics do

def get_activity_topics(activity) do
activity
|> Object.normalize()
|> Object.normalize(fetch: false)
|> generate_topics(activity)
|> List.flatten()
end


+ 1
- 1
lib/pleroma/activity/queries.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Activity.Queries do


+ 1
- 1
lib/pleroma/activity/search.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Activity.Search do


+ 12
- 3
lib/pleroma/application.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Application do
@@ -297,7 +297,16 @@ defmodule Pleroma.Application do

@spec limiters_setup() :: :ok
def limiters_setup do
[Pleroma.Web.RichMedia.Helpers, Pleroma.Web.MediaProxy]
|> Enum.each(&ConcurrentLimiter.new(&1, 1, 0))
config = Config.get(ConcurrentLimiter, [])

[Pleroma.Web.RichMedia.Helpers, Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy]
|> Enum.each(fn module ->
mod_config = Keyword.get(config, module, [])

max_running = Keyword.get(mod_config, :max_running, 5)
max_waiting = Keyword.get(mod_config, :max_waiting, 5)

ConcurrentLimiter.new(module, max_running, max_waiting)
end)
end
end

+ 26
- 1
lib/pleroma/application_requirements.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.ApplicationRequirements do
@@ -24,6 +24,7 @@ defmodule Pleroma.ApplicationRequirements do
|> check_migrations_applied!()
|> check_welcome_message_config!()
|> check_rum!()
|> check_repo_pool_size!()
|> handle_result()
end

@@ -188,6 +189,30 @@ defmodule Pleroma.ApplicationRequirements do

defp check_system_commands!(result), do: result

defp check_repo_pool_size!(:ok) do
if Pleroma.Config.get([Pleroma.Repo, :pool_size], 10) != 10 and
not Pleroma.Config.get([:dangerzone, :override_repo_pool_size], false) do
Logger.error("""
!!!CONFIG WARNING!!!

The database pool size has been altered from the recommended value of 10.

Please revert or ensure your database is tuned appropriately and then set
`config :pleroma, :dangerzone, override_repo_pool_size: true`.

If you are experiencing database timeouts, please check the "Optimizing
your PostgreSQL performance" section in the documentation. If you still
encounter issues after that, please open an issue on the tracker.
""")

{:error, "Repo.pool_size different than recommended value."}
else
:ok
end
end

defp check_repo_pool_size!(result), do: result

defp check_filter(filter, command_required) do
filters = Config.get([Pleroma.Upload, :filters])



+ 1
- 1
lib/pleroma/bbs/authenticator.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.BBS.Authenticator do


+ 1
- 1
lib/pleroma/bbs/handler.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.BBS.Handler do


+ 1
- 1
lib/pleroma/bookmark.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Bookmark do


+ 19
- 0
lib/pleroma/caching.ex View File

@@ -0,0 +1,19 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Caching do
@callback get!(Cachex.cache(), any()) :: any()
@callback get(Cachex.cache(), any()) :: {atom(), any()}
@callback put(Cachex.cache(), any(), any(), Keyword.t()) :: {Cachex.status(), boolean()}
@callback put(Cachex.cache(), any(), any()) :: {Cachex.status(), boolean()}
@callback fetch!(Cachex.cache(), any(), function() | nil) :: any()
# @callback del(Cachex.cache(), any(), Keyword.t()) :: {Cachex.status(), boolean()}
@callback del(Cachex.cache(), any()) :: {Cachex.status(), boolean()}
@callback stream!(Cachex.cache(), any()) :: Enumerable.t()
@callback expire_at(Cachex.cache(), binary(), number()) :: {Cachex.status(), boolean()}
@callback exists?(Cachex.cache(), any()) :: {Cachex.status(), boolean()}
@callback execute!(Cachex.cache(), function()) :: any()
@callback get_and_update(Cachex.cache(), any(), function()) ::
{:commit | :ignore, any()}
end

+ 5
- 3
lib/pleroma/captcha.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Captcha do
@@ -7,6 +7,8 @@ defmodule Pleroma.Captcha do
alias Plug.Crypto.KeyGenerator
alias Plug.Crypto.MessageEncryptor

@cachex Pleroma.Config.get([:cachex, :provider], Cachex)

@doc """
Ask the configured captcha service for a new captcha
"""
@@ -86,7 +88,7 @@ defmodule Pleroma.Captcha do
end

defp validate_usage(token) do
if is_nil(Cachex.get!(:used_captcha_cache, token)) do
if is_nil(@cachex.get!(:used_captcha_cache, token)) do
:ok
else
{:error, :already_used}
@@ -95,7 +97,7 @@ defmodule Pleroma.Captcha do

defp mark_captcha_as_used(token) do
ttl = seconds_valid() |> :timer.seconds()
Cachex.put(:used_captcha_cache, token, true, ttl: ttl)
@cachex.put(:used_captcha_cache, token, true, ttl: ttl)
end

defp method, do: Pleroma.Config.get!([__MODULE__, :method])


+ 1
- 1
lib/pleroma/captcha/kocaptcha.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Captcha.Kocaptcha do


+ 1
- 1
lib/pleroma/captcha/native.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Captcha.Native do


+ 1
- 1
lib/pleroma/captcha/service.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Captcha.Service do


+ 1
- 1
lib/pleroma/chat.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Chat do


+ 1
- 1
lib/pleroma/chat/message_reference.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Chat.MessageReference do


+ 1
- 1
lib/pleroma/clippy.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Clippy do


+ 6
- 1
lib/pleroma/config.ex View File

@@ -1,16 +1,20 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Config do
@behaviour Pleroma.Config.Getting
defmodule Error do
defexception [:message]
end

@impl true
def get(key), do: get(key, nil)

@impl true
def get([key], default), do: get(key, default)

@impl true
def get([_ | _] = path, default) do
case fetch(path) do
{:ok, value} -> value
@@ -18,6 +22,7 @@ defmodule Pleroma.Config do
end
end

@impl true
def get(key, default) do
Application.get_env(:pleroma, key, default)
end


+ 24
- 2
lib/pleroma/config/deprecation_warnings.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Config.DeprecationWarnings do
@@ -40,7 +40,8 @@ defmodule Pleroma.Config.DeprecationWarnings do
:ok <- check_welcome_message_config(),
:ok <- check_gun_pool_options(),
:ok <- check_activity_expiration_config(),
:ok <- check_remote_ip_plug_name() do
:ok <- check_remote_ip_plug_name(),
:ok <- check_uploders_s3_public_endpoint() do
:ok
else
_ ->
@@ -193,4 +194,25 @@ defmodule Pleroma.Config.DeprecationWarnings do
warning_preface
)
end

@spec check_uploders_s3_public_endpoint() :: :ok | nil
def check_uploders_s3_public_endpoint do
s3_config = Pleroma.Config.get([Pleroma.Uploaders.S3])

use_old_config = Keyword.has_key?(s3_config, :public_endpoint)

if use_old_config do
Logger.error("""
!!!DEPRECATION WARNING!!!
Your config is using the old setting for controlling the URL of media uploaded to your S3 bucket.\n
Please make the following change at your earliest convenience.\n
\n* `config :pleroma, Pleroma.Uploaders.S3, public_endpoint` is now equal to:
\n* `config :pleroma, Pleroma.Upload, base_url`
""")

:error
else
:ok
end
end
end

+ 8
- 0
lib/pleroma/config/getting.ex View File

@@ -0,0 +1,8 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Config.Getting do
@callback get(any()) :: any()
@callback get(any(), any()) :: any()
end

+ 1
- 1
lib/pleroma/config/helpers.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Config.Helpers do


+ 1
- 1
lib/pleroma/config/holder.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Config.Holder do


+ 1
- 1
lib/pleroma/config/loader.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Config.Loader do


+ 1
- 1
lib/pleroma/config/oban.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Config.Oban do


+ 1
- 1
lib/pleroma/config/transfer_task.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Config.TransferTask do


+ 13
- 3
lib/pleroma/config_db.ex View File

@@ -1,12 +1,12 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.ConfigDB do
use Ecto.Schema

import Ecto.Changeset
import Ecto.Query, only: [select: 3]
import Ecto.Query, only: [select: 3, from: 2]
import Pleroma.Web.Gettext

alias __MODULE__
@@ -41,8 +41,18 @@ defmodule Pleroma.ConfigDB do
end)
end

@spec get_all_by_group(atom() | String.t()) :: [t()]
def get_all_by_group(group) do
from(c in ConfigDB, where: c.group == ^group) |> Repo.all()
end

@spec get_by_group_and_key(atom() | String.t(), atom() | String.t()) :: t() | nil
def get_by_group_and_key(group, key) do
get_by_params(%{group: group, key: key})
end

@spec get_by_params(map()) :: ConfigDB.t() | nil
def get_by_params(params), do: Repo.get_by(ConfigDB, params)
def get_by_params(%{group: _, key: _} = params), do: Repo.get_by(ConfigDB, params)

@spec changeset(ConfigDB.t(), map()) :: Changeset.t()
def changeset(config, params \\ %{}) do


+ 1
- 1
lib/pleroma/constants.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Constants do


+ 3
- 2
lib/pleroma/conversation.ex View File

@@ -1,10 +1,11 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Conversation do
alias Pleroma.Conversation.Participation
alias Pleroma.Conversation.Participation.RecipientShip
alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.User
use Ecto.Schema
@@ -58,7 +59,7 @@ defmodule Pleroma.Conversation do
def create_or_bump_for(activity, opts \\ []) do
with true <- Pleroma.Web.ActivityPub.Visibility.is_direct?(activity),
"Create" <- activity.data["type"],
object <- Pleroma.Object.normalize(activity),
%Object{} = object <- Object.normalize(activity, fetch: false),
true <- object.data["type"] in ["Note", "Question"],
ap_id when is_binary(ap_id) and byte_size(ap_id) > 0 <- object.data["context"] do
{:ok, conversation} = create_for_ap_id(ap_id)


+ 1
- 1
lib/pleroma/conversation/participation.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Conversation.Participation do


+ 1
- 1
lib/pleroma/conversation/participation/recipient_ship.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Conversation.Participation.RecipientShip do


+ 1
- 1
lib/pleroma/counter_cache.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.CounterCache do


+ 1
- 1
lib/pleroma/delivery.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Delivery do


+ 1
- 1
lib/pleroma/docs/generator.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Docs.Generator do


+ 1
- 1
lib/pleroma/docs/json.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Docs.JSON do


+ 1
- 1
lib/pleroma/docs/markdown.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Docs.Markdown do


+ 1
- 1
lib/pleroma/earmark_renderer.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
#
# This file is derived from Earmark, under the following copyright:


+ 1
- 1
lib/pleroma/ecto_enums.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

import EctoEnum


+ 1
- 1
lib/pleroma/ecto_type/activity_pub/object_validators/date_time.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.DateTime do


+ 1
- 1
lib/pleroma/ecto_type/activity_pub/object_validators/emoji.ex View File

@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.Emoji do


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save