mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2026-02-15 17:16:57 +00:00
Compare commits
45 commits
f6c0972ac4
...
619aabbf68
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
619aabbf68 | ||
|
|
6877aacd49 | ||
|
|
fb415d304e | ||
|
|
bd4977a4ed | ||
|
|
dfb910399a | ||
|
|
8effcafa95 | ||
|
|
fef11eb280 | ||
|
|
467a3728d9 | ||
|
|
a1e999dc58 | ||
|
|
6895d8efd4 | ||
|
|
69f75c3ee4 | ||
|
|
6dde9d02bb | ||
|
|
354dfbfb31 | ||
|
|
4656e1ca67 | ||
|
|
16e3176895 | ||
|
|
093053257e | ||
|
|
6bfc2f05ae | ||
|
|
d0dfd0f88d | ||
|
|
8eb9b888bf | ||
|
|
941c99d317 | ||
|
|
b35573c6b5 | ||
|
|
bfae2e790d | ||
|
|
45bf97c1a1 | ||
|
|
a50458ad23 | ||
|
|
108a0fb3a9 | ||
|
|
6e6e3e1ae6 | ||
|
|
c577c8d058 | ||
|
|
de970927fd | ||
|
|
d4cd9987e9 | ||
|
|
57216baa0b | ||
|
|
90b268bca2 | ||
|
|
9eadc07361 | ||
|
|
ecfcb47a09 | ||
|
|
b160a73924 | ||
|
|
a051497b59 | ||
|
|
336cdf9a66 | ||
|
|
a84e091c4e | ||
|
|
7d2518a9ae | ||
|
|
40f4f1a99f | ||
|
|
d36e9c8a0d | ||
|
|
6279907754 | ||
|
|
1c685ea41a | ||
|
|
ec6ffa4fdf | ||
|
|
4693dc837b | ||
|
|
feda4d0718 |
64 changed files with 466 additions and 125 deletions
28
.woodpecker.yml
Normal file
28
.woodpecker.yml
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
when:
|
||||||
|
- event:
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
steps:
|
||||||
|
test:
|
||||||
|
image: elixir:1.19-alpine
|
||||||
|
environment:
|
||||||
|
MIX_ENV: test
|
||||||
|
DB_HOST: postgres
|
||||||
|
DB_PORT: 5432
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache build-base cmake exiftool ffmpeg file-dev git openssl
|
||||||
|
- adduser -D -h /home/testuser testuser
|
||||||
|
- mkdir -p /home/testuser/.mix /home/testuser/.hex
|
||||||
|
- chown -R testuser:testuser . /home/testuser
|
||||||
|
- su testuser -c "HOME=/home/testuser mix local.hex --force"
|
||||||
|
- su testuser -c "HOME=/home/testuser mix local.rebar --force"
|
||||||
|
- su testuser -c "HOME=/home/testuser mix deps.get"
|
||||||
|
- su testuser -c "HOME=/home/testuser mix test"
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:13-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: pleroma_test
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<img src="https://git.pleroma.social/pleroma/pleroma/uploads/8cec84f5a084d887339f57deeb8a293e/pleroma-banner-vector-nopad-notext.svg" width="300px" />
|
<img src="https://git.pleroma.social/attachments/06a95f5a-7cac-42ad-8b1d-1483f1739f38" width="300px" />
|
||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
||||||
|
|
|
||||||
1
changelog.d/elixir-1-19.fix
Normal file
1
changelog.d/elixir-1-19.fix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Fixed Elixir 1.19 warnings
|
||||||
1
changelog.d/logger-backends.change
Normal file
1
changelog.d/logger-backends.change
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Changed how Logger is configured due to changes in Elixir and added deprecation warnings for the old configuration format
|
||||||
|
|
@ -133,10 +133,9 @@ config :pleroma, Pleroma.Web.Endpoint,
|
||||||
]
|
]
|
||||||
|
|
||||||
# Configures Elixir's Logger
|
# Configures Elixir's Logger
|
||||||
config :logger, backends: [:console]
|
config :logger, :default_handler, level: :debug
|
||||||
|
|
||||||
config :logger, :console,
|
config :logger, :default_formatter,
|
||||||
level: :debug,
|
|
||||||
format: "\n$time $metadata[$level] $message\n",
|
format: "\n$time $metadata[$level] $message\n",
|
||||||
metadata: [:actor, :path, :type, :user]
|
metadata: [:actor, :path, :type, :user]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ config :pleroma, Pleroma.Emails.Mailer, adapter: Swoosh.Adapters.Local
|
||||||
# different ports.
|
# different ports.
|
||||||
|
|
||||||
# Do not include timestamps in development logs
|
# Do not include timestamps in development logs
|
||||||
config :logger, Logger.Backends.Console, format: "$metadata[$level] $message\n"
|
config :logger, :default_formatter, format: "$metadata[$level] $message\n"
|
||||||
|
|
||||||
# Set a higher stacktrace during development. Avoid configuring such
|
# Set a higher stacktrace during development. Avoid configuring such
|
||||||
# in production as building large stacktraces may be expensive.
|
# in production as building large stacktraces may be expensive.
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@ config :pleroma, Pleroma.Web.Endpoint,
|
||||||
config :phoenix, serve_endpoints: true
|
config :phoenix, serve_endpoints: true
|
||||||
|
|
||||||
# Do not print debug messages in production
|
# Do not print debug messages in production
|
||||||
config :logger, Logger.Backends.Console, level: :info
|
config :logger, :default_handler, level: :info
|
||||||
config :logger, :console, level: :info
|
|
||||||
config :logger, :ex_syslogger, level: :info
|
config :logger, :ex_syslogger, level: :info
|
||||||
|
|
||||||
# ## SSL Support
|
# ## SSL Support
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,11 @@ config :pleroma, Pleroma.Captcha,
|
||||||
method: Pleroma.Captcha.Mock
|
method: Pleroma.Captcha.Mock
|
||||||
|
|
||||||
# Print only warnings and errors during test
|
# Print only warnings and errors during test
|
||||||
config :logger, :console,
|
config :logger, :default_handler, level: :warning
|
||||||
level: :warning,
|
|
||||||
format: "\n[$level] $message\n"
|
config :logger, :default_formatter,
|
||||||
|
format: "\n[$level] $message\n",
|
||||||
|
colors: [enabled: false]
|
||||||
|
|
||||||
config :pleroma, :auth, oauth_consumer_strategies: []
|
config :pleroma, :auth, oauth_consumer_strategies: []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -858,21 +858,23 @@ Web Push Notifications configuration. You can use the mix task `mix web_push.gen
|
||||||
* ``private_key``: VAPID private key
|
* ``private_key``: VAPID private key
|
||||||
|
|
||||||
## :logger
|
## :logger
|
||||||
* `backends`: `:console` is used to send logs to stdout, `{ExSyslogger, :ex_syslogger}` to log to syslog
|
* Logging to console/stdout is done by default, use `{ExSyslogger, :ex_syslogger}` to log to syslog
|
||||||
|
|
||||||
An example to enable ONLY ExSyslogger (f/ex in ``prod.secret.exs``) with info and debug suppressed:
|
An example to enable ONLY ExSyslogger (f/ex in ``prod.secret.exs``) with info and debug suppressed:
|
||||||
```elixir
|
```elixir
|
||||||
config :logger,
|
config :pleroma, :logger,
|
||||||
backends: [{ExSyslogger, :ex_syslogger}]
|
backends: [{ExSyslogger, :ex_syslogger}]
|
||||||
|
|
||||||
|
config :logger, default_handler: false
|
||||||
|
|
||||||
config :logger, :ex_syslogger,
|
config :logger, :ex_syslogger,
|
||||||
level: :warning
|
level: :warning
|
||||||
```
|
```
|
||||||
|
|
||||||
Another example, keeping console output and adding the pid to syslog output:
|
Another example, keeping console output and adding the pid to syslog output:
|
||||||
```elixir
|
```elixir
|
||||||
config :logger,
|
config :pleroma, :logger,
|
||||||
backends: [:console, {ExSyslogger, :ex_syslogger}]
|
backends: [{ExSyslogger, :ex_syslogger}]
|
||||||
|
|
||||||
config :logger, :ex_syslogger,
|
config :logger, :ex_syslogger,
|
||||||
level: :warning,
|
level: :warning,
|
||||||
|
|
@ -883,23 +885,22 @@ See: [logger’s documentation](https://hexdocs.pm/logger/Logger.html) and [ex_s
|
||||||
|
|
||||||
An example of logging info to local syslog, but debug to console:
|
An example of logging info to local syslog, but debug to console:
|
||||||
```elixir
|
```elixir
|
||||||
config :logger,
|
config :pleroma, :logger,
|
||||||
backends: [ {ExSyslogger, :ex_syslogger}, :console ],
|
backends: [{ExSyslogger, :ex_syslogger}]
|
||||||
level: :info
|
|
||||||
|
|
||||||
config :logger, :ex_syslogger,
|
config :logger, :ex_syslogger,
|
||||||
level: :info,
|
level: :info,
|
||||||
ident: "pleroma",
|
ident: "pleroma",
|
||||||
format: "$metadata[$level] $message"
|
format: "$metadata[$level] $message"
|
||||||
|
|
||||||
config :logger, :console,
|
config :logger, :default_handler,
|
||||||
level: :debug,
|
level: :debug
|
||||||
|
|
||||||
|
config :logger, :default_formatter,
|
||||||
format: "\n$time $metadata[$level] $message\n",
|
format: "\n$time $metadata[$level] $message\n",
|
||||||
metadata: [:request_id]
|
metadata: [:request_id]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Database options
|
## Database options
|
||||||
|
|
||||||
### RUM indexing for full text search
|
### RUM indexing for full text search
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
## Required dependencies
|
## Required dependencies
|
||||||
|
|
||||||
* PostgreSQL >=11.0
|
* PostgreSQL >=11.0
|
||||||
* Elixir >=1.15.0 <1.19
|
* Elixir >=1.15.0, <1.20
|
||||||
* Erlang OTP >=23.0.0 (supported: <28)
|
* Erlang OTP >=24.0.0 (supported: <29)
|
||||||
* git
|
* git
|
||||||
* file / libmagic
|
* file / libmagic
|
||||||
* gcc or clang
|
* gcc or clang
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ defmodule Pleroma.Application do
|
||||||
# every time the application is restarted, so we disable module
|
# every time the application is restarted, so we disable module
|
||||||
# conflicts at runtime
|
# conflicts at runtime
|
||||||
Code.compiler_options(ignore_module_conflict: true)
|
Code.compiler_options(ignore_module_conflict: true)
|
||||||
|
configure_logger()
|
||||||
Pleroma.Telemetry.Logger.attach()
|
Pleroma.Telemetry.Logger.attach()
|
||||||
Config.Holder.save_default()
|
Config.Holder.save_default()
|
||||||
Pleroma.HTML.compile_scrubbers()
|
Pleroma.HTML.compile_scrubbers()
|
||||||
|
|
@ -113,6 +114,44 @@ defmodule Pleroma.Application do
|
||||||
Supervisor.start_link(children, opts)
|
Supervisor.start_link(children, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def configure_logger do
|
||||||
|
Config.get([:logger, :backends], [])
|
||||||
|
|> Enum.each(fn backend ->
|
||||||
|
case backend_to_logger(backend) do
|
||||||
|
{:ok, logger} ->
|
||||||
|
add_logger(logger)
|
||||||
|
|
||||||
|
{:error, :console_backend} ->
|
||||||
|
Logger.warning(":console is no longer considered a backend and is enabled by default")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp add_logger(backend) do
|
||||||
|
case LoggerBackends.add(backend) do
|
||||||
|
{:ok, _} ->
|
||||||
|
Logger.debug("Successfully added logger backend: #{inspect(backend)}")
|
||||||
|
|
||||||
|
{:error, :already_present} ->
|
||||||
|
:ok
|
||||||
|
|
||||||
|
{:error, reason} ->
|
||||||
|
Logger.error("Failed to add logger backend #{inspect(backend)}: #{inspect(reason)}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp backend_to_logger(:console), do: {:error, :console_backend}
|
||||||
|
|
||||||
|
defp backend_to_logger({:ex_syslogger = backend, name}) do
|
||||||
|
Logger.warning(
|
||||||
|
"Configuration {:#{backend}, :#{name}} is incorrect. Use {ExSyslogger, :#{name}} instead!"
|
||||||
|
)
|
||||||
|
|
||||||
|
{:ok, {ExSyslogger, name}}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp backend_to_logger(backend), do: {:ok, backend}
|
||||||
|
|
||||||
def load_custom_modules do
|
def load_custom_modules do
|
||||||
dir = Config.get([:modules, :runtime_dir])
|
dir = Config.get([:modules, :runtime_dir])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
||||||
"\n* `config :pleroma, :instance, mrf_transparency_exclusions` is now `config :pleroma, :mrf, transparency_exclusions`"}
|
"\n* `config :pleroma, :instance, mrf_transparency_exclusions` is now `config :pleroma, :mrf, transparency_exclusions`"}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@logger_formatter_config_knobs [:colors, :format, :metadata, :truncate, :utc_log]
|
||||||
|
|
||||||
def check_exiftool_filter do
|
def check_exiftool_filter do
|
||||||
filters = Config.get([Pleroma.Upload]) |> Keyword.get(:filters, [])
|
filters = Config.get([Pleroma.Upload]) |> Keyword.get(:filters, [])
|
||||||
|
|
||||||
|
|
@ -218,7 +220,8 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
||||||
check_quarantined_instances_tuples(),
|
check_quarantined_instances_tuples(),
|
||||||
check_transparency_exclusions_tuples(),
|
check_transparency_exclusions_tuples(),
|
||||||
check_simple_policy_tuples(),
|
check_simple_policy_tuples(),
|
||||||
check_exiftool_filter()
|
check_exiftool_filter(),
|
||||||
|
check_deprecated_logger_config()
|
||||||
]
|
]
|
||||||
|> Enum.reduce(:ok, fn
|
|> Enum.reduce(:ok, fn
|
||||||
:ok, :ok -> :ok
|
:ok, :ok -> :ok
|
||||||
|
|
@ -415,4 +418,72 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp merge_deprecated_logger_config(config) do
|
||||||
|
formatter_config = Enum.filter(config, fn {k, _} -> k in @logger_formatter_config_knobs end)
|
||||||
|
formatter = Logger.default_formatter(formatter_config)
|
||||||
|
log_level = Keyword.get(config, :level, nil)
|
||||||
|
|
||||||
|
if Config.get(:env) != :test do
|
||||||
|
Logger.debug("""
|
||||||
|
Reconfiguring console Logger with deprecated configuration syntax.
|
||||||
|
Handler configuration:
|
||||||
|
log_level: #{inspect(log_level)}
|
||||||
|
|
||||||
|
Formatter:
|
||||||
|
#{inspect(formatter)}
|
||||||
|
""")
|
||||||
|
|
||||||
|
if log_level, do: :logger.update_handler_config(:default, :level, log_level)
|
||||||
|
:logger.update_handler_config(:default, :formatter, formatter)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@spec check_deprecated_logger_config() :: :ok | :error
|
||||||
|
def check_deprecated_logger_config do
|
||||||
|
backends_config = Application.get_env(:logger, :backends)
|
||||||
|
console_config = Application.get_env(:logger, :console)
|
||||||
|
|
||||||
|
# NOTE: No need to merge the old backends config since it still works.
|
||||||
|
# And new configuration will just add new Logger backends.
|
||||||
|
backend =
|
||||||
|
if backends_config do
|
||||||
|
Logger.warning("""
|
||||||
|
!!!DEPRECATION WARNING!!!
|
||||||
|
Your configuration is using deprecated syntax for configuring backends of Elixir's logger.
|
||||||
|
`config :logger, backends: [...]` is deprecated syntax due to changes in Elixir.
|
||||||
|
Please update your configuration at your earliest convenience to use:
|
||||||
|
`config :pleroma, :logger, backends: [...]`
|
||||||
|
|
||||||
|
Note: `:console` is no longer considered a backend and is used by default, you can disable it using:
|
||||||
|
`config :logger, :default_handler: false`
|
||||||
|
""")
|
||||||
|
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
console =
|
||||||
|
if console_config do
|
||||||
|
Logger.warning("""
|
||||||
|
!!!DEPRECATION WARNING!!!
|
||||||
|
Your configuration is using deprecated syntax for configuring logging to console.
|
||||||
|
`config :logger, :console` is deprecated syntax due to changes in Elixir.
|
||||||
|
Please update your configuration at your earliest convenience to use
|
||||||
|
`config :logger, default_handler` and `config :logger, :default_formatter`.
|
||||||
|
|
||||||
|
Note: `:default_handler` is used only for the `level` setting. All other configurations go under
|
||||||
|
`:default_formatter`. For more info visit: https://hexdocs.pm/logger/Logger.html#module-backends-and-backwards-compatibility
|
||||||
|
""")
|
||||||
|
|
||||||
|
merge_deprecated_logger_config(console_config)
|
||||||
|
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
if backend or console, do: :error, else: :ok
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ defmodule Pleroma.Marker do
|
||||||
|
|
||||||
defp get_marker(user, timeline) do
|
defp get_marker(user, timeline) do
|
||||||
case Repo.find_resource(get_query(user, timeline)) do
|
case Repo.find_resource(get_query(user, timeline)) do
|
||||||
{:ok, marker} -> %__MODULE__{marker | user: user}
|
{:ok, %__MODULE__{} = marker} -> %{marker | user: user}
|
||||||
_ -> %__MODULE__{timeline: timeline, user_id: user.id}
|
_ -> %__MODULE__{timeline: timeline, user_id: user.id}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ defmodule Pleroma.MFA.Changeset do
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
def disable(%Ecto.Changeset{} = changeset, force \\ false) do
|
def disable(%Ecto.Changeset{} = changeset, force \\ false) do
|
||||||
settings =
|
%Settings{} =
|
||||||
|
settings =
|
||||||
changeset
|
changeset
|
||||||
|> Ecto.Changeset.apply_changes()
|
|> Ecto.Changeset.apply_changes()
|
||||||
|> MFA.fetch_settings()
|
|> MFA.fetch_settings()
|
||||||
|
|
@ -20,20 +21,20 @@ defmodule Pleroma.MFA.Changeset do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def disable_totp(%User{multi_factor_authentication_settings: settings} = user) do
|
def disable_totp(%User{multi_factor_authentication_settings: %Settings{} = settings} = user) do
|
||||||
user
|
user
|
||||||
|> put_change(%Settings{settings | totp: %Settings.TOTP{}})
|
|> put_change(%Settings{settings | totp: %Settings.TOTP{}})
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirm_totp(%User{multi_factor_authentication_settings: settings} = user) do
|
def confirm_totp(%User{multi_factor_authentication_settings: %Settings{} = settings} = user) do
|
||||||
totp_settings = %Settings.TOTP{settings.totp | confirmed: true}
|
totp_settings = %Settings.TOTP{(%Settings.TOTP{} = settings.totp) | confirmed: true}
|
||||||
|
|
||||||
user
|
user
|
||||||
|> put_change(%Settings{settings | totp: totp_settings, enabled: true})
|
|> put_change(%Settings{settings | totp: totp_settings, enabled: true})
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_totp(%User{} = user, attrs) do
|
def setup_totp(%User{} = user, attrs) do
|
||||||
mfa_settings = MFA.fetch_settings(user)
|
%Settings{} = mfa_settings = MFA.fetch_settings(user)
|
||||||
|
|
||||||
totp_settings =
|
totp_settings =
|
||||||
%Settings.TOTP{}
|
%Settings.TOTP{}
|
||||||
|
|
@ -46,7 +47,7 @@ defmodule Pleroma.MFA.Changeset do
|
||||||
def cast_backup_codes(%User{} = user, codes) do
|
def cast_backup_codes(%User{} = user, codes) do
|
||||||
user
|
user
|
||||||
|> put_change(%Settings{
|
|> put_change(%Settings{
|
||||||
user.multi_factor_authentication_settings
|
(%Settings{} = user.multi_factor_authentication_settings)
|
||||||
| backup_codes: codes
|
| backup_codes: codes
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ defmodule Pleroma.Upload do
|
||||||
def store(upload, opts \\ []) do
|
def store(upload, opts \\ []) do
|
||||||
opts = get_opts(opts)
|
opts = get_opts(opts)
|
||||||
|
|
||||||
with {:ok, upload} <- prepare_upload(upload, opts),
|
with {:ok, %__MODULE__{} = upload} <- prepare_upload(upload, opts),
|
||||||
upload = %__MODULE__{upload | path: upload.path || "#{upload.id}/#{upload.name}"},
|
upload = %__MODULE__{upload | path: upload.path || "#{upload.id}/#{upload.name}"},
|
||||||
{:ok, upload} <- Pleroma.Upload.Filter.filter(opts.filters, upload),
|
{:ok, upload} <- Pleroma.Upload.Filter.filter(opts.filters, upload),
|
||||||
description = get_description(upload),
|
description = get_description(upload),
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ defmodule Pleroma.Utils do
|
||||||
dir
|
dir
|
||||||
|> File.ls!()
|
|> File.ls!()
|
||||||
|> Enum.map(&Path.join(dir, &1))
|
|> Enum.map(&Path.join(dir, &1))
|
||||||
|> Kernel.ParallelCompiler.compile()
|
|> Kernel.ParallelCompiler.compile(return_diagnostics: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy do
|
||||||
@moduledoc "Adds expiration to all local Create activities"
|
@moduledoc "Adds expiration to all local Create activities"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(activity) do
|
def filter(activity) do
|
||||||
activity =
|
activity =
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy do
|
||||||
|
@moduledoc "Prevent followbots from following with a bit of heuristic"
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
@moduledoc "Prevent followbots from following with a bit of heuristic"
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
|
||||||
|
|
||||||
# XXX: this should become User.normalize_by_ap_id() or similar, really.
|
# XXX: this should become User.normalize_by_ap_id() or similar, really.
|
||||||
defp normalize_by_ap_id(%{"id" => id}), do: User.get_cached_by_ap_id(id)
|
defp normalize_by_ap_id(%{"id" => id}), do: User.get_cached_by_ap_id(id)
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy do
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,13 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.AntiMentionSpamPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.AntiMentionSpamPolicy do
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
defp user_has_posted?(%User{} = u), do: u.note_count > 0
|
defp user_has_posted?(%User{} = u), do: u.note_count > 0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,12 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.DropPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.DropPolicy do
|
||||||
require Logger
|
|
||||||
@moduledoc "Drop and log everything received"
|
@moduledoc "Drop and log everything received"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
require Logger
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(activity) do
|
def filter(activity) do
|
||||||
Logger.debug("REJECTING #{inspect(activity)}")
|
Logger.debug("REJECTING #{inspect(activity)}")
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.EmojiPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.EmojiPolicy do
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
alias Pleroma.Object.Updater
|
alias Pleroma.Object.Updater
|
||||||
|
|
@ -10,7 +12,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.EmojiPolicy do
|
||||||
|
|
||||||
@moduledoc "Reject or force-unlisted emojis with certain URLs or names"
|
@moduledoc "Reject or force-unlisted emojis with certain URLs or names"
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
defp config_remove_url do
|
defp config_remove_url do
|
||||||
Pleroma.Config.get([:mrf_emoji, :remove_url], [])
|
Pleroma.Config.get([:mrf_emoji, :remove_url], [])
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,13 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrepended do
|
defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrepended do
|
||||||
alias Pleroma.Object
|
|
||||||
|
|
||||||
@moduledoc "Ensure a re: is prepended on replies to a post with a Subject"
|
@moduledoc "Ensure a re: is prepended on replies to a post with a Subject"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
alias Pleroma.Object
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@reply_prefix Regex.compile!("^re:[[:space:]]*", [:caseless])
|
@reply_prefix Regex.compile!("^re:[[:space:]]*", [:caseless])
|
||||||
|
|
||||||
def history_awareness, do: :auto
|
def history_awareness, do: :auto
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,15 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.FollowBotPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.FollowBotPolicy do
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.CommonAPI
|
alias Pleroma.Web.CommonAPI
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(activity) do
|
def filter(activity) do
|
||||||
with follower_nickname <- Config.get([:mrf_follow_bot, :follower_nickname]),
|
with follower_nickname <- Config.get([:mrf_follow_bot, :follower_nickname]),
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,12 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicy do
|
||||||
alias Pleroma.User
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
|
||||||
@moduledoc "Remove bot posts from federated timeline"
|
@moduledoc "Remove bot posts from federated timeline"
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
alias Pleroma.User
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.ForceMention do
|
defmodule Pleroma.Web.ActivityPub.MRF.ForceMention do
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
defp get_author(url) do
|
defp get_author(url) do
|
||||||
with %Object{data: %{"actor" => actor}} <- Object.normalize(url, fetch: false),
|
with %Object{data: %{"actor" => actor}} <- Object.normalize(url, fetch: false),
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,15 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.ForceMentionsInContent do
|
defmodule Pleroma.Web.ActivityPub.MRF.ForceMentionsInContent do
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
alias Pleroma.Formatter
|
alias Pleroma.Formatter
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def history_awareness, do: :auto
|
def history_awareness, do: :auto
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.HashtagPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.HashtagPolicy do
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
|
|
@ -14,7 +16,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.HashtagPolicy do
|
||||||
Note: This MRF Policy is always enabled, if you want to disable it you have to set empty lists.
|
Note: This MRF Policy is always enabled, if you want to disable it you have to set empty lists.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def history_awareness, do: :manual
|
def history_awareness, do: :manual
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do
|
||||||
|
@moduledoc "Block activities with too much mentions (configurable)"
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
@moduledoc "Block activities with too much mentions (configurable)"
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
|
||||||
|
|
||||||
defp delist_activity(activity, threshold) when threshold > 0 do
|
defp delist_activity(activity, threshold) when threshold > 0 do
|
||||||
follower_collection = User.get_cached_by_ap_id(activity["actor"]).follower_address
|
follower_collection = User.get_cached_by_ap_id(activity["actor"]).follower_address
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.InlineQuotePolicy do
|
||||||
@moduledoc "Force a quote line into the message content."
|
@moduledoc "Force a quote line into the message content."
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
defp build_inline_quote(template, url) do
|
defp build_inline_quote(template, url) do
|
||||||
quote_line = String.replace(template, "{url}", "<a href=\"#{url}\">#{url}</a>")
|
quote_line = String.replace(template, "{url}", "<a href=\"#{url}\">#{url}</a>")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicy do
|
||||||
|
@moduledoc "Reject or Word-Replace activities with a keyword or regex"
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
alias Pleroma.Web.ActivityPub.MRF.Utils
|
alias Pleroma.Web.ActivityPub.MRF.Utils
|
||||||
|
|
||||||
@moduledoc "Reject or Word-Replace activities with a keyword or regex"
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
|
||||||
|
|
||||||
defp string_matches?(string, pattern) when is_binary(pattern) do
|
defp string_matches?(string, pattern) when is_binary(pattern) do
|
||||||
String.contains?(string, pattern)
|
String.contains?(string, pattern)
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy do
|
||||||
@moduledoc "Preloads any attachments in the MediaProxy cache by prefetching them"
|
@moduledoc "Preloads any attachments in the MediaProxy cache by prefetching them"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.HTTP
|
alias Pleroma.HTTP
|
||||||
alias Pleroma.Web.MediaProxy
|
alias Pleroma.Web.MediaProxy
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,10 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicy do
|
||||||
@moduledoc "Block activities which mention a user"
|
@moduledoc "Block activities which mention a user"
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(%{"type" => "Create"} = activity) do
|
def filter(%{"type" => "Create"} = activity) do
|
||||||
reject_actors = Pleroma.Config.get([:mrf_mention, :actors], [])
|
reject_actors = Pleroma.Config.get([:mrf_mention, :actors], [])
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.NoEmptyPolicy do
|
||||||
@moduledoc "Filter local activities which have no content"
|
@moduledoc "Filter local activities which have no content"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.Web.Endpoint
|
alias Pleroma.Web.Endpoint
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.NoOpPolicy do
|
||||||
@moduledoc "Does nothing (lets the messages go through unmodified)"
|
@moduledoc "Does nothing (lets the messages go through unmodified)"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(activity) do
|
def filter(activity) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicy do
|
||||||
@moduledoc "Ensure no content placeholder is present (such as the dot from mastodon)"
|
@moduledoc "Ensure no content placeholder is present (such as the dot from mastodon)"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def history_awareness, do: :auto
|
def history_awareness, do: :auto
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkup do
|
defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkup do
|
||||||
@moduledoc "Scrub configured hypertext markup"
|
@moduledoc "Scrub configured hypertext markup"
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.HTML
|
alias Pleroma.HTML
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def history_awareness, do: :auto
|
def history_awareness, do: :auto
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.NsfwApiPolicy do
|
||||||
- `unlist`: Unlist all detected NSFW content? Default: `false`
|
- `unlist`: Unlist all detected NSFW content? Default: `false`
|
||||||
- `reject`: Reject all detected NSFW content (takes precedence)? Default: `false`
|
- `reject`: Reject all detected NSFW content (takes precedence)? Default: `false`
|
||||||
"""
|
"""
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.Constants
|
alias Pleroma.Constants
|
||||||
alias Pleroma.HTTP
|
alias Pleroma.HTTP
|
||||||
|
|
@ -46,7 +48,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.NsfwApiPolicy do
|
||||||
require Logger
|
require Logger
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@policy :mrf_nsfw_api
|
@policy :mrf_nsfw_api
|
||||||
|
|
||||||
def build_request_url(url) do
|
def build_request_url(url) do
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,15 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy do
|
||||||
|
@moduledoc "Filter activities depending on their age"
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
@moduledoc "Filter activities depending on their age"
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
|
||||||
|
|
||||||
defp check_date(%{"object" => %{"published" => published}} = activity) do
|
defp check_date(%{"object" => %{"published" => published}} = activity) do
|
||||||
with %DateTime{} = now <- DateTime.utc_now(),
|
with %DateTime{} = now <- DateTime.utc_now(),
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,12 @@ defmodule Pleroma.Web.ActivityPub.MRF.Policy do
|
||||||
}
|
}
|
||||||
@callback history_awareness() :: :auto | :manual
|
@callback history_awareness() :: :auto | :manual
|
||||||
@optional_callbacks config_description: 0, history_awareness: 0, id_filter: 1
|
@optional_callbacks config_description: 0, history_awareness: 0, id_filter: 1
|
||||||
|
|
||||||
|
defmacro __using__(_) do
|
||||||
|
quote do
|
||||||
|
# Otherwise Pleroma.Docs.Generator.list_behaviour_implementations fails
|
||||||
|
# since the Elixir compiler doesn't automatically load the module since v1.19.
|
||||||
|
@compile {:autoload, true}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,13 @@ defmodule Pleroma.Web.ActivityPub.MRF.QuietReply do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
QuietReply alters the scope of activities from local users when replying by enforcing them to be "Unlisted" or "Quiet Public". This delivers the activity to all the expected recipients and instances, but it will not be published in the Federated / The Whole Known Network timelines. It will still be published to the Home timelines of the user's followers and visible to anyone who opens the thread.
|
QuietReply alters the scope of activities from local users when replying by enforcing them to be "Unlisted" or "Quiet Public". This delivers the activity to all the expected recipients and instances, but it will not be published in the Federated / The Whole Known Network timelines. It will still be published to the Home timelines of the user's followers and visible to anyone who opens the thread.
|
||||||
"""
|
"""
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def history_awareness, do: :auto
|
def history_awareness, do: :auto
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.QuoteToLinkTagPolicy do
|
||||||
@moduledoc "Force a Link tag for posts quoting another post. (may break outgoing federation of quote posts with older Pleroma versions)"
|
@moduledoc "Force a Link tag for posts quoting another post. (may break outgoing federation of quote posts with older Pleroma versions)"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonFixes
|
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonFixes
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,12 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublic do
|
defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublic do
|
||||||
@moduledoc "Rejects non-public (followers-only, direct) activities"
|
@moduledoc "Rejects non-public (followers-only, direct) activities"
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.RemoteReportPolicy do
|
||||||
@moduledoc "Drop remote reports if they don't contain enough information."
|
@moduledoc "Drop remote reports if they don't contain enough information."
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
||||||
@moduledoc "Filter activities depending on their origin instance"
|
@moduledoc "Filter activities depending on their origin instance"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.FollowingRelationship
|
alias Pleroma.FollowingRelationship
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,14 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicy do
|
||||||
|
@moduledoc "Detect new emojis by their shortcode and steals them"
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
|
|
||||||
@moduledoc "Detect new emojis by their shortcode and steals them"
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
|
||||||
|
|
||||||
defp accept_host?(host), do: host in Config.get([:mrf_steal_emoji, :hosts], [])
|
defp accept_host?(host), do: host in Config.get([:mrf_steal_emoji, :hosts], [])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,14 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.SubchainPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.SubchainPolicy do
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.Web.ActivityPub.MRF
|
alias Pleroma.Web.ActivityPub.MRF
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
defp lookup_subchain(actor) do
|
defp lookup_subchain(actor) do
|
||||||
with matches <- Config.get([:mrf_subchain, :match_actor]),
|
with matches <- Config.get([:mrf_subchain, :match_actor]),
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.TagPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.TagPolicy do
|
||||||
alias Pleroma.User
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Apply policies based on user tags
|
Apply policies based on user tags
|
||||||
|
|
||||||
|
|
@ -18,6 +16,11 @@ defmodule Pleroma.Web.ActivityPub.MRF.TagPolicy do
|
||||||
- `mrf_tag:disable-remote-subscription`: Reject non-local follow requests
|
- `mrf_tag:disable-remote-subscription`: Reject non-local follow requests
|
||||||
- `mrf_tag:disable-any-subscription`: Reject any follow requests
|
- `mrf_tag:disable-any-subscription`: Reject any follow requests
|
||||||
"""
|
"""
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
alias Pleroma.User
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,13 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy do
|
||||||
alias Pleroma.Config
|
|
||||||
|
|
||||||
@moduledoc "Accept-list of users from specified instances"
|
@moduledoc "Accept-list of users from specified instances"
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
alias Pleroma.Config
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
defp filter_by_list(activity, []), do: {:ok, activity}
|
defp filter_by_list(activity, []), do: {:ok, activity}
|
||||||
|
|
||||||
defp filter_by_list(%{"actor" => actor} = activity, allow_list) do
|
defp filter_by_list(%{"actor" => actor} = activity, allow_list) do
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,10 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicy do
|
defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicy do
|
||||||
@moduledoc "Filter activities which belong to certain activity vocabularies"
|
@moduledoc "Filter activities which belong to certain activity vocabularies"
|
||||||
|
|
||||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
use Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(%{"type" => "Undo", "object" => object} = activity) do
|
def filter(%{"type" => "Undo", "object" => object} = activity) do
|
||||||
with {:ok, _} <- filter(object) do
|
with {:ok, _} <- filter(object) do
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,14 @@ defmodule Pleroma.Web.ApiSpec.CastAndValidate do
|
||||||
OpenApiSpex.cast_and_validate(spec, operation, conn, content_type, cast_opts)
|
OpenApiSpex.cast_and_validate(spec, operation, conn, content_type, cast_opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp cast_and_validate(spec, operation, conn, content_type, false = _strict, cast_opts) do
|
defp cast_and_validate(
|
||||||
|
spec,
|
||||||
|
operation,
|
||||||
|
%Conn{} = conn,
|
||||||
|
content_type,
|
||||||
|
false = _strict,
|
||||||
|
cast_opts
|
||||||
|
) do
|
||||||
case OpenApiSpex.cast_and_validate(spec, operation, conn, content_type) do
|
case OpenApiSpex.cast_and_validate(spec, operation, conn, content_type) do
|
||||||
{:ok, conn} ->
|
{:ok, conn} ->
|
||||||
{:ok, conn}
|
{:ok, conn}
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@ defmodule Pleroma.Web.ApiSpec.RenderError do
|
||||||
def call(conn, errors) do
|
def call(conn, errors) do
|
||||||
errors =
|
errors =
|
||||||
Enum.map(errors, fn
|
Enum.map(errors, fn
|
||||||
%{name: nil, reason: :invalid_enum} = err ->
|
%OpenApiSpex.Cast.Error{name: nil, reason: :invalid_enum} = err ->
|
||||||
%OpenApiSpex.Cast.Error{err | name: err.value}
|
%{err | name: err.value}
|
||||||
|
|
||||||
%{name: nil} = err ->
|
%OpenApiSpex.Cast.Error{name: nil} = err ->
|
||||||
%OpenApiSpex.Cast.Error{err | name: List.last(err.path)}
|
%{err | name: List.last(err.path)}
|
||||||
|
|
||||||
err ->
|
err ->
|
||||||
err
|
err
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
|> validate()
|
|> validate()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp listen_object(draft) do
|
defp listen_object(%__MODULE__{} = draft) do
|
||||||
object =
|
object =
|
||||||
draft.params
|
draft.params
|
||||||
|> Map.take([:album, :artist, :title, :length])
|
|> Map.take([:album, :artist, :title, :length])
|
||||||
|
|
@ -102,20 +102,20 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
%__MODULE__{draft | object: object}
|
%__MODULE__{draft | object: object}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp put_params(draft, params) do
|
defp put_params(%__MODULE__{} = draft, params) do
|
||||||
params = Map.put_new(params, :in_reply_to_status_id, params[:in_reply_to_id])
|
params = Map.put_new(params, :in_reply_to_status_id, params[:in_reply_to_id])
|
||||||
%__MODULE__{draft | params: params}
|
%__MODULE__{draft | params: params}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp status(%{params: %{status: status}} = draft) do
|
defp status(%__MODULE__{params: %{status: status}} = draft) do
|
||||||
%__MODULE__{draft | status: String.trim(status)}
|
%__MODULE__{draft | status: String.trim(status)}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp summary(%{params: params} = draft) do
|
defp summary(%__MODULE__{params: params} = draft) do
|
||||||
%__MODULE__{draft | summary: Map.get(params, :spoiler_text, "")}
|
%__MODULE__{draft | summary: Map.get(params, :spoiler_text, "")}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp full_payload(%{status: status, summary: summary} = draft) do
|
defp full_payload(%__MODULE__{status: status, summary: summary} = draft) do
|
||||||
full_payload = String.trim(status <> summary)
|
full_payload = String.trim(status <> summary)
|
||||||
|
|
||||||
case Utils.validate_character_limit(full_payload, draft.attachments) do
|
case Utils.validate_character_limit(full_payload, draft.attachments) do
|
||||||
|
|
@ -124,7 +124,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp attachments(%{params: params} = draft) do
|
defp attachments(%__MODULE__{params: params} = draft) do
|
||||||
attachments = Utils.attachments_from_ids(params, draft.user)
|
attachments = Utils.attachments_from_ids(params, draft.user)
|
||||||
draft = %__MODULE__{draft | attachments: attachments}
|
draft = %__MODULE__{draft | attachments: attachments}
|
||||||
|
|
||||||
|
|
@ -134,9 +134,10 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp in_reply_to(%{params: %{in_reply_to_status_id: ""}} = draft), do: draft
|
defp in_reply_to(%__MODULE__{params: %{in_reply_to_status_id: ""}} = draft), do: draft
|
||||||
|
|
||||||
defp in_reply_to(%{params: %{in_reply_to_status_id: id}} = draft) when is_binary(id) do
|
defp in_reply_to(%__MODULE__{params: %{in_reply_to_status_id: id}} = draft)
|
||||||
|
when is_binary(id) do
|
||||||
# If a post was deleted all its activities (except the newly added Delete) are purged too,
|
# If a post was deleted all its activities (except the newly added Delete) are purged too,
|
||||||
# thus lookup by Create db ID will yield nil just as if it never existed in the first place.
|
# thus lookup by Create db ID will yield nil just as if it never existed in the first place.
|
||||||
#
|
#
|
||||||
|
|
@ -166,13 +167,16 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp in_reply_to(%{params: %{in_reply_to_status_id: %Activity{} = in_reply_to}} = draft) do
|
defp in_reply_to(
|
||||||
|
%__MODULE__{params: %{in_reply_to_status_id: %Activity{} = in_reply_to}} = draft
|
||||||
|
) do
|
||||||
%__MODULE__{draft | in_reply_to: in_reply_to}
|
%__MODULE__{draft | in_reply_to: in_reply_to}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp in_reply_to(draft), do: draft
|
defp in_reply_to(draft), do: draft
|
||||||
|
|
||||||
defp quote_post(%{params: %{quoted_status_id: id}} = draft) when not_empty_string(id) do
|
defp quote_post(%__MODULE__{params: %{quoted_status_id: id}} = draft)
|
||||||
|
when not_empty_string(id) do
|
||||||
case Activity.get_by_id_with_object(id) do
|
case Activity.get_by_id_with_object(id) do
|
||||||
%Activity{} = activity ->
|
%Activity{} = activity ->
|
||||||
%__MODULE__{draft | quote_post: activity}
|
%__MODULE__{draft | quote_post: activity}
|
||||||
|
|
@ -188,12 +192,12 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
|
|
||||||
defp quote_post(draft), do: draft
|
defp quote_post(draft), do: draft
|
||||||
|
|
||||||
defp in_reply_to_conversation(draft) do
|
defp in_reply_to_conversation(%__MODULE__{} = draft) do
|
||||||
in_reply_to_conversation = Participation.get(draft.params[:in_reply_to_conversation_id])
|
in_reply_to_conversation = Participation.get(draft.params[:in_reply_to_conversation_id])
|
||||||
%__MODULE__{draft | in_reply_to_conversation: in_reply_to_conversation}
|
%__MODULE__{draft | in_reply_to_conversation: in_reply_to_conversation}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp visibility(%{params: params} = draft) do
|
defp visibility(%__MODULE__{params: params} = draft) do
|
||||||
case CommonAPI.get_visibility(params, draft.in_reply_to, draft.in_reply_to_conversation) do
|
case CommonAPI.get_visibility(params, draft.in_reply_to, draft.in_reply_to_conversation) do
|
||||||
{visibility, "direct"} when visibility != "direct" ->
|
{visibility, "direct"} when visibility != "direct" ->
|
||||||
add_error(draft, dgettext("errors", "The message visibility must be direct"))
|
add_error(draft, dgettext("errors", "The message visibility must be direct"))
|
||||||
|
|
@ -226,14 +230,14 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
|
|
||||||
defp quoting_visibility(draft), do: draft
|
defp quoting_visibility(draft), do: draft
|
||||||
|
|
||||||
defp expires_at(draft) do
|
defp expires_at(%__MODULE__{} = draft) do
|
||||||
case CommonAPI.check_expiry_date(draft.params[:expires_in]) do
|
case CommonAPI.check_expiry_date(draft.params[:expires_in]) do
|
||||||
{:ok, expires_at} -> %__MODULE__{draft | expires_at: expires_at}
|
{:ok, expires_at} -> %__MODULE__{draft | expires_at: expires_at}
|
||||||
{:error, message} -> add_error(draft, message)
|
{:error, message} -> add_error(draft, message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp poll(draft) do
|
defp poll(%__MODULE__{} = draft) do
|
||||||
case Utils.make_poll_data(draft.params) do
|
case Utils.make_poll_data(draft.params) do
|
||||||
{:ok, {poll, poll_emoji}} ->
|
{:ok, {poll, poll_emoji}} ->
|
||||||
%__MODULE__{draft | extra: poll, emoji: Map.merge(draft.emoji, poll_emoji)}
|
%__MODULE__{draft | extra: poll, emoji: Map.merge(draft.emoji, poll_emoji)}
|
||||||
|
|
@ -243,7 +247,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp content(%{mentions: mentions} = draft) do
|
defp content(%__MODULE__{mentions: mentions} = draft) do
|
||||||
{content_html, mentioned_users, tags} = Utils.make_content_html(draft)
|
{content_html, mentioned_users, tags} = Utils.make_content_html(draft)
|
||||||
|
|
||||||
mentioned_ap_ids =
|
mentioned_ap_ids =
|
||||||
|
|
@ -257,22 +261,22 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
%__MODULE__{draft | content_html: content_html, mentions: mentions, tags: tags}
|
%__MODULE__{draft | content_html: content_html, mentions: mentions, tags: tags}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp to_and_cc(draft) do
|
defp to_and_cc(%__MODULE__{} = draft) do
|
||||||
{to, cc} = Utils.get_to_and_cc(draft)
|
{to, cc} = Utils.get_to_and_cc(draft)
|
||||||
%__MODULE__{draft | to: to, cc: cc}
|
%__MODULE__{draft | to: to, cc: cc}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp context(draft) do
|
defp context(%__MODULE__{} = draft) do
|
||||||
context = Utils.make_context(draft.in_reply_to, draft.in_reply_to_conversation)
|
context = Utils.make_context(draft.in_reply_to, draft.in_reply_to_conversation)
|
||||||
%__MODULE__{draft | context: context}
|
%__MODULE__{draft | context: context}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp sensitive(draft) do
|
defp sensitive(%__MODULE__{} = draft) do
|
||||||
sensitive = draft.params[:sensitive]
|
sensitive = draft.params[:sensitive]
|
||||||
%__MODULE__{draft | sensitive: sensitive}
|
%__MODULE__{draft | sensitive: sensitive}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp language(draft) do
|
defp language(%__MODULE__{} = draft) do
|
||||||
language =
|
language =
|
||||||
with language <- draft.params[:language],
|
with language <- draft.params[:language],
|
||||||
true <- good_locale_code?(language) do
|
true <- good_locale_code?(language) do
|
||||||
|
|
@ -284,7 +288,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
%__MODULE__{draft | language: language}
|
%__MODULE__{draft | language: language}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp object(draft) do
|
defp object(%__MODULE__{} = draft) do
|
||||||
emoji = Map.merge(Pleroma.Emoji.Formatter.get_emoji_map(draft.full_payload), draft.emoji)
|
emoji = Map.merge(Pleroma.Emoji.Formatter.get_emoji_map(draft.full_payload), draft.emoji)
|
||||||
|
|
||||||
# Sometimes people create posts with subject containing emoji,
|
# Sometimes people create posts with subject containing emoji,
|
||||||
|
|
@ -328,12 +332,12 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
%__MODULE__{draft | object: object}
|
%__MODULE__{draft | object: object}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp preview?(draft) do
|
defp preview?(%__MODULE__{} = draft) do
|
||||||
preview? = Pleroma.Web.Utils.Params.truthy_param?(draft.params[:preview])
|
preview? = Pleroma.Web.Utils.Params.truthy_param?(draft.params[:preview])
|
||||||
%__MODULE__{draft | preview?: preview?}
|
%__MODULE__{draft | preview?: preview?}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp changes(draft) do
|
defp changes(%__MODULE__{} = draft) do
|
||||||
direct? = draft.visibility == "direct"
|
direct? = draft.visibility == "direct"
|
||||||
additional = %{"cc" => draft.cc, "directMessage" => direct?}
|
additional = %{"cc" => draft.cc, "directMessage" => direct?}
|
||||||
|
|
||||||
|
|
@ -359,7 +363,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|
||||||
defp with_valid(%{valid?: true} = draft, func), do: func.(draft)
|
defp with_valid(%{valid?: true} = draft, func), do: func.(draft)
|
||||||
defp with_valid(draft, _func), do: draft
|
defp with_valid(draft, _func), do: draft
|
||||||
|
|
||||||
defp add_error(draft, message) do
|
defp add_error(%__MODULE__{} = draft, message) do
|
||||||
%__MODULE__{draft | valid?: false, errors: [message | draft.errors]}
|
%__MODULE__{draft | valid?: false, errors: [message | draft.errors]}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
7
mix.exs
7
mix.exs
|
|
@ -15,6 +15,13 @@ defmodule Pleroma.Mixfile do
|
||||||
aliases: aliases(),
|
aliases: aliases(),
|
||||||
deps: deps(),
|
deps: deps(),
|
||||||
test_coverage: [tool: :covertool, summary: true],
|
test_coverage: [tool: :covertool, summary: true],
|
||||||
|
test_ignore_filters: [
|
||||||
|
"test/credo/check/consistency/file_location.ex",
|
||||||
|
"test/fixtures/config/temp.exported_from_db.secret.exs",
|
||||||
|
"test/fixtures/config/temp.secret.exs",
|
||||||
|
"test/fixtures/modules/good_mrf.ex",
|
||||||
|
"test/fixtures/modules/runtime_module.ex"
|
||||||
|
],
|
||||||
# Docs
|
# Docs
|
||||||
name: "Pleroma",
|
name: "Pleroma",
|
||||||
homepage_url: "https://pleroma.social/",
|
homepage_url: "https://pleroma.social/",
|
||||||
|
|
|
||||||
35
test/pleroma/application_test.exs
Normal file
35
test/pleroma/application_test.exs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2026 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.ApplicationTest do
|
||||||
|
use Pleroma.DataCase
|
||||||
|
|
||||||
|
import ExUnit.CaptureLog
|
||||||
|
|
||||||
|
describe "config :pleroma, :logger, backends: [{:ex_syslogger, :ex_syslogger}]" do
|
||||||
|
setup do
|
||||||
|
clear_config([:logger, :backends], [{:ex_syslogger, :ex_syslogger}])
|
||||||
|
end
|
||||||
|
|
||||||
|
test "is handled" do
|
||||||
|
log = capture_log(fn -> Pleroma.Application.configure_logger() end)
|
||||||
|
|
||||||
|
assert log =~
|
||||||
|
"Configuration {:ex_syslogger, :ex_syslogger} is incorrect. Use {ExSyslogger, :ex_syslogger} instead!"
|
||||||
|
|
||||||
|
assert log =~ "Successfully added logger backend: {ExSyslogger, :ex_syslogger}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "config :pleroma, :logger, :backends: [:console]" do
|
||||||
|
setup do
|
||||||
|
clear_config([:logger, :backends], [:console])
|
||||||
|
end
|
||||||
|
|
||||||
|
test "emits a warning" do
|
||||||
|
assert capture_log(fn -> Pleroma.Application.configure_logger() end) =~
|
||||||
|
":console is no longer considered a backend and is enabled by default"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Config.DeprecationWarningsTest do
|
defmodule Pleroma.Config.DeprecationWarningsTest do
|
||||||
use ExUnit.Case
|
use ExUnit.Case, async: false
|
||||||
use Pleroma.Tests.Helpers
|
use Pleroma.Tests.Helpers
|
||||||
|
|
||||||
import ExUnit.CaptureLog
|
import ExUnit.CaptureLog
|
||||||
|
|
@ -11,6 +11,8 @@ defmodule Pleroma.Config.DeprecationWarningsTest do
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.Config.DeprecationWarnings
|
alias Pleroma.Config.DeprecationWarnings
|
||||||
|
|
||||||
|
require Logger
|
||||||
|
|
||||||
describe "filter exiftool" do
|
describe "filter exiftool" do
|
||||||
test "gives warning when still used" do
|
test "gives warning when still used" do
|
||||||
clear_config(
|
clear_config(
|
||||||
|
|
@ -388,4 +390,59 @@ defmodule Pleroma.Config.DeprecationWarningsTest do
|
||||||
end) =~
|
end) =~
|
||||||
"Your config is using the old namespace for the Shoutbox configuration."
|
"Your config is using the old namespace for the Shoutbox configuration."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "check_deprecated_logger_config" do
|
||||||
|
setup do
|
||||||
|
initial_console = Application.get_env(:logger, :console, nil)
|
||||||
|
initial_backends = Application.get_env(:logger, :backends, nil)
|
||||||
|
|
||||||
|
Application.put_env(:logger, :console, level: :all)
|
||||||
|
Application.put_env(:logger, :backends, [:console])
|
||||||
|
|
||||||
|
on_exit(fn ->
|
||||||
|
if initial_console do
|
||||||
|
Application.put_env(:logger, :console, initial_console)
|
||||||
|
else
|
||||||
|
Application.delete_env(:logger, :console)
|
||||||
|
end
|
||||||
|
|
||||||
|
if initial_backends do
|
||||||
|
Application.put_env(:logger, :backends, initial_backends)
|
||||||
|
else
|
||||||
|
Application.delete_env(:logger, :backends)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "warns on deprecated syntax" do
|
||||||
|
log =
|
||||||
|
capture_log(fn ->
|
||||||
|
Pleroma.Config.DeprecationWarnings.check_deprecated_logger_config()
|
||||||
|
end)
|
||||||
|
|
||||||
|
assert log =~
|
||||||
|
"""
|
||||||
|
!!!DEPRECATION WARNING!!!
|
||||||
|
Your configuration is using deprecated syntax for configuring backends of Elixir's logger.
|
||||||
|
`config :logger, backends: [...]` is deprecated syntax due to changes in Elixir.
|
||||||
|
Please update your configuration at your earliest convenience to use:
|
||||||
|
`config :pleroma, :logger, backends: [...]`
|
||||||
|
|
||||||
|
Note: `:console` is no longer considered a backend and is used by default, you can disable it using:
|
||||||
|
`config :logger, :default_handler: false`
|
||||||
|
"""
|
||||||
|
|
||||||
|
assert log =~
|
||||||
|
"""
|
||||||
|
!!!DEPRECATION WARNING!!!
|
||||||
|
Your configuration is using deprecated syntax for configuring logging to console.
|
||||||
|
`config :logger, :console` is deprecated syntax due to changes in Elixir.
|
||||||
|
Please update your configuration at your earliest convenience to use
|
||||||
|
`config :logger, default_handler` and `config :logger, :default_formatter`.
|
||||||
|
|
||||||
|
Note: `:default_handler` is used only for the `level` setting. All other configurations go under
|
||||||
|
`:default_formatter`. For more info visit: https://hexdocs.pm/logger/Logger.html#module-backends-and-backwards-compatibility
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -273,24 +273,28 @@ defmodule Pleroma.ConfigDBTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "sigil" do
|
test "sigil" do
|
||||||
assert ConfigDB.to_elixir_types("~r[comp[lL][aA][iI][nN]er]") == ~r/comp[lL][aA][iI][nN]er/
|
assert ConfigDB.to_elixir_types("~r[comp[lL][aA][iI][nN]er]").source ==
|
||||||
|
~r/comp[lL][aA][iI][nN]er/.source
|
||||||
end
|
end
|
||||||
|
|
||||||
test "link sigil" do
|
test "link sigil" do
|
||||||
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/") == ~r/https:\/\/example.com/
|
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/").source ==
|
||||||
|
~r/https:\/\/example.com/.source
|
||||||
end
|
end
|
||||||
|
|
||||||
test "link sigil with um modifiers" do
|
test "link sigil with um modifiers" do
|
||||||
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/um") ==
|
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/um").source ==
|
||||||
~r/https:\/\/example.com/um
|
~r/https:\/\/example.com/um.source
|
||||||
end
|
end
|
||||||
|
|
||||||
test "link sigil with i modifier" do
|
test "link sigil with i modifier" do
|
||||||
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/i") == ~r/https:\/\/example.com/i
|
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/i").source ==
|
||||||
|
~r/https:\/\/example.com/i.source
|
||||||
end
|
end
|
||||||
|
|
||||||
test "link sigil with s modifier" do
|
test "link sigil with s modifier" do
|
||||||
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/s") == ~r/https:\/\/example.com/s
|
assert ConfigDB.to_elixir_types("~r/https:\/\/example.com/s").source ==
|
||||||
|
~r/https:\/\/example.com/s.source
|
||||||
end
|
end
|
||||||
|
|
||||||
test "raise if valid delimiter not found" do
|
test "raise if valid delimiter not found" do
|
||||||
|
|
@ -460,11 +464,11 @@ defmodule Pleroma.ConfigDBTest do
|
||||||
test "complex keyword with sigil" do
|
test "complex keyword with sigil" do
|
||||||
assert ConfigDB.to_elixir_types([
|
assert ConfigDB.to_elixir_types([
|
||||||
%{"tuple" => [":federated_timeline_removal", []]},
|
%{"tuple" => [":federated_timeline_removal", []]},
|
||||||
%{"tuple" => [":reject", ["~r/comp[lL][aA][iI][nN]er/"]]},
|
%{"tuple" => [":reject", [~r/comp[lL][aA][iI][nN]er/.source]]},
|
||||||
%{"tuple" => [":replace", []]}
|
%{"tuple" => [":replace", []]}
|
||||||
]) == [
|
]) == [
|
||||||
federated_timeline_removal: [],
|
federated_timeline_removal: [],
|
||||||
reject: [~r/comp[lL][aA][iI][nN]er/],
|
reject: [~r/comp[lL][aA][iI][nN]er/.source],
|
||||||
replace: []
|
replace: []
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,12 @@ defmodule Pleroma.MarkerTest do
|
||||||
insert(:notification, user: user, activity: insert(:note_activity))
|
insert(:notification, user: user, activity: insert(:note_activity))
|
||||||
insert(:notification, user: user, activity: insert(:note_activity))
|
insert(:notification, user: user, activity: insert(:note_activity))
|
||||||
insert(:marker, timeline: "home", user: user)
|
insert(:marker, timeline: "home", user: user)
|
||||||
|
%Marker{} = refreshed_marker = refresh_record(marker)
|
||||||
|
|
||||||
assert Marker.get_markers(
|
assert Marker.get_markers(
|
||||||
user,
|
user,
|
||||||
["notifications"]
|
["notifications"]
|
||||||
) == [%Marker{refresh_record(marker) | unread_count: 2}]
|
) == [%{refreshed_marker | unread_count: 2}]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ defmodule Pleroma.RepoTest do
|
||||||
describe "get_assoc/2" do
|
describe "get_assoc/2" do
|
||||||
test "get assoc from preloaded data" do
|
test "get assoc from preloaded data" do
|
||||||
user = %User{name: "Agent Smith"}
|
user = %User{name: "Agent Smith"}
|
||||||
token = %Pleroma.Web.OAuth.Token{insert(:oauth_token) | user: user}
|
%Pleroma.Web.OAuth.Token{} = token = insert(:oauth_token)
|
||||||
|
token = %{token | user: user}
|
||||||
assert Repo.get_assoc(token, :user) == {:ok, user}
|
assert Repo.get_assoc(token, :user) == {:ok, user}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1495,8 +1495,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
||||||
%{test_file: test_file}
|
%{test_file: test_file}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "strips / from filename", %{test_file: file} do
|
test "strips / from filename", %{test_file: %Plug.Upload{} = file} do
|
||||||
file = %Plug.Upload{file | filename: "../../../../../nested/bad.jpg"}
|
file = %{file | filename: "../../../../../nested/bad.jpg"}
|
||||||
{:ok, %Object{} = object} = ActivityPub.upload(file)
|
{:ok, %Object{} = object} = ActivityPub.upload(file)
|
||||||
[%{"href" => href}] = object.data["url"]
|
[%{"href" => href}] = object.data["url"]
|
||||||
assert Regex.match?(~r"/bad.jpg$", href)
|
assert Regex.match?(~r"/bad.jpg$", href)
|
||||||
|
|
@ -1757,10 +1757,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
||||||
{:ok, list} = Pleroma.List.create("foo", user)
|
{:ok, list} = Pleroma.List.create("foo", user)
|
||||||
{:ok, list} = Pleroma.List.follow(list, member)
|
{:ok, list} = Pleroma.List.follow(list, member)
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
|
{:ok, %Activity{} = activity} =
|
||||||
|
CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
|
||||||
|
|
||||||
activity = Repo.preload(activity, :bookmark)
|
activity = Repo.preload(activity, :bookmark)
|
||||||
activity = %Activity{activity | thread_muted?: !!activity.thread_muted?}
|
activity = %{activity | thread_muted?: !!activity.thread_muted?}
|
||||||
|
|
||||||
assert ActivityPub.fetch_activities([], %{user: user}) == [activity]
|
assert ActivityPub.fetch_activities([], %{user: user}) == [activity]
|
||||||
end
|
end
|
||||||
|
|
@ -1960,7 +1961,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
||||||
assert User.following?(follower, old_user)
|
assert User.following?(follower, old_user)
|
||||||
assert User.following?(follower_move_opted_out, old_user)
|
assert User.following?(follower_move_opted_out, old_user)
|
||||||
|
|
||||||
assert {:ok, activity} = ActivityPub.move(old_user, new_user)
|
assert {:ok, %Activity{} = activity} = ActivityPub.move(old_user, new_user)
|
||||||
|
|
||||||
assert %Activity{
|
assert %Activity{
|
||||||
actor: ^old_ap_id,
|
actor: ^old_ap_id,
|
||||||
|
|
@ -1992,7 +1993,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
||||||
assert User.following?(follower_move_opted_out, old_user)
|
assert User.following?(follower_move_opted_out, old_user)
|
||||||
refute User.following?(follower_move_opted_out, new_user)
|
refute User.following?(follower_move_opted_out, new_user)
|
||||||
|
|
||||||
activity = %Activity{activity | object: nil}
|
activity = %{activity | object: nil}
|
||||||
|
|
||||||
assert [%Notification{activity: ^activity}] = Notification.for_user(follower)
|
assert [%Notification{activity: ^activity}] = Notification.for_user(follower)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,25 @@ defmodule Pleroma.Web.ActivityPub.MRFTest do
|
||||||
|
|
||||||
alias Pleroma.Web.ActivityPub.MRF
|
alias Pleroma.Web.ActivityPub.MRF
|
||||||
|
|
||||||
|
defp regexes_match!([], []), do: true
|
||||||
|
|
||||||
|
defp regexes_match!([authority | authority_rest], [checked | checked_rest]) do
|
||||||
|
authority.source == checked.source and regexes_match!(authority_rest, checked_rest)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp regexes_match!(_, _), do: false
|
||||||
|
|
||||||
test "subdomains_regex/1" do
|
test "subdomains_regex/1" do
|
||||||
assert MRF.subdomains_regex(["unsafe.tld", "*.unsafe.tld"]) == [
|
regexes = MRF.subdomains_regex(["unsafe.tld", "*.unsafe.tld"])
|
||||||
~r/^unsafe.tld$/i,
|
|
||||||
~r/^(.*\.)*unsafe.tld$/i
|
assert regexes_match!(regexes, [~r/^unsafe.tld$/i, ~r/^(.*\.)*unsafe.tld$/i])
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "subdomain_match/2" do
|
describe "subdomain_match/2" do
|
||||||
test "common domains" do
|
test "common domains" do
|
||||||
regexes = MRF.subdomains_regex(["unsafe.tld", "unsafe2.tld"])
|
regexes = MRF.subdomains_regex(["unsafe.tld", "unsafe2.tld"])
|
||||||
|
|
||||||
assert regexes == [~r/^unsafe.tld$/i, ~r/^unsafe2.tld$/i]
|
assert regexes_match!(regexes, [~r/^unsafe.tld$/i, ~r/^unsafe2.tld$/i])
|
||||||
|
|
||||||
assert MRF.subdomain_match?(regexes, "unsafe.tld")
|
assert MRF.subdomain_match?(regexes, "unsafe.tld")
|
||||||
assert MRF.subdomain_match?(regexes, "unsafe2.tld")
|
assert MRF.subdomain_match?(regexes, "unsafe2.tld")
|
||||||
|
|
@ -32,7 +39,7 @@ defmodule Pleroma.Web.ActivityPub.MRFTest do
|
||||||
test "wildcard domains with one subdomain" do
|
test "wildcard domains with one subdomain" do
|
||||||
regexes = MRF.subdomains_regex(["*.unsafe.tld"])
|
regexes = MRF.subdomains_regex(["*.unsafe.tld"])
|
||||||
|
|
||||||
assert regexes == [~r/^(.*\.)*unsafe.tld$/i]
|
assert regexes_match!(regexes, [~r/^(.*\.)*unsafe.tld$/i])
|
||||||
|
|
||||||
assert MRF.subdomain_match?(regexes, "unsafe.tld")
|
assert MRF.subdomain_match?(regexes, "unsafe.tld")
|
||||||
assert MRF.subdomain_match?(regexes, "sub.unsafe.tld")
|
assert MRF.subdomain_match?(regexes, "sub.unsafe.tld")
|
||||||
|
|
@ -43,7 +50,7 @@ defmodule Pleroma.Web.ActivityPub.MRFTest do
|
||||||
test "wildcard domains with two subdomains" do
|
test "wildcard domains with two subdomains" do
|
||||||
regexes = MRF.subdomains_regex(["*.unsafe.tld"])
|
regexes = MRF.subdomains_regex(["*.unsafe.tld"])
|
||||||
|
|
||||||
assert regexes == [~r/^(.*\.)*unsafe.tld$/i]
|
assert regexes_match!(regexes, [~r/^(.*\.)*unsafe.tld$/i])
|
||||||
|
|
||||||
assert MRF.subdomain_match?(regexes, "unsafe.tld")
|
assert MRF.subdomain_match?(regexes, "unsafe.tld")
|
||||||
assert MRF.subdomain_match?(regexes, "sub.sub.unsafe.tld")
|
assert MRF.subdomain_match?(regexes, "sub.sub.unsafe.tld")
|
||||||
|
|
@ -54,7 +61,7 @@ defmodule Pleroma.Web.ActivityPub.MRFTest do
|
||||||
test "matches are case-insensitive" do
|
test "matches are case-insensitive" do
|
||||||
regexes = MRF.subdomains_regex(["UnSafe.TLD", "UnSAFE2.Tld"])
|
regexes = MRF.subdomains_regex(["UnSafe.TLD", "UnSAFE2.Tld"])
|
||||||
|
|
||||||
assert regexes == [~r/^UnSafe.TLD$/i, ~r/^UnSAFE2.Tld$/i]
|
assert regexes_match!(regexes, [~r/^UnSafe.TLD$/i, ~r/^UnSAFE2.Tld$/i])
|
||||||
|
|
||||||
assert MRF.subdomain_match?(regexes, "UNSAFE.TLD")
|
assert MRF.subdomain_match?(regexes, "UNSAFE.TLD")
|
||||||
assert MRF.subdomain_match?(regexes, "UNSAFE2.TLD")
|
assert MRF.subdomain_match?(regexes, "UNSAFE2.TLD")
|
||||||
|
|
|
||||||
|
|
@ -129,8 +129,8 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
|
||||||
assert :ok == File.rm(Path.absname("test/tmp/large_binary.data"))
|
assert :ok == File.rm(Path.absname("test/tmp/large_binary.data"))
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Do not allow nested filename", %{conn: conn, image: image} do
|
test "Do not allow nested filename", %{conn: conn, image: %Plug.Upload{} = image} do
|
||||||
image = %Plug.Upload{
|
image = %{
|
||||||
image
|
image
|
||||||
| filename: "../../../../../nested/file.jpg"
|
| filename: "../../../../../nested/file.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3068,7 +3068,11 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
|> json_response_and_validate_schema(:ok)
|
|> json_response_and_validate_schema(:ok)
|
||||||
|
|
||||||
{:ok, a_expires_at, 0} = DateTime.from_iso8601(a_expires_at)
|
{:ok, a_expires_at, 0} = DateTime.from_iso8601(a_expires_at)
|
||||||
assert DateTime.diff(expires_at, a_expires_at) == 0
|
|
||||||
|
assert DateTime.diff(
|
||||||
|
DateTime.truncate(expires_at, :second),
|
||||||
|
DateTime.truncate(a_expires_at, :second)
|
||||||
|
) == 0
|
||||||
|
|
||||||
%{conn: conn} = oauth_access(["read:statuses"])
|
%{conn: conn} = oauth_access(["read:statuses"])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,8 @@ defmodule Pleroma.Tests.Helpers do
|
||||||
defmacro clear_config(config_path, temp_setting) do
|
defmacro clear_config(config_path, temp_setting) do
|
||||||
# NOTE: `clear_config([section, key], value)` != `clear_config([section], key: value)` (!)
|
# NOTE: `clear_config([section, key], value)` != `clear_config([section], key: value)` (!)
|
||||||
# Displaying a warning to prevent unintentional clearing of all but one keys in section
|
# Displaying a warning to prevent unintentional clearing of all but one keys in section
|
||||||
if Keyword.keyword?(temp_setting) and length(temp_setting) == 1 do
|
if is_list(config_path) and length(config_path) == 1 and Keyword.keyword?(temp_setting) and
|
||||||
|
Keyword.keys(temp_setting) == [:key] do
|
||||||
Logger.warning(
|
Logger.warning(
|
||||||
"Please change `clear_config([section], key: value)` to `clear_config([section, key], value)`"
|
"Please change `clear_config([section], key: value)` to `clear_config([section, key], value)`"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue