forked from AkkomaGang/akkoma
added warning to use old keys
This commit is contained in:
parent
db0224d174
commit
7991ddad58
5 changed files with 51 additions and 0 deletions
|
@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- OGP rich media parser merged with TwitterCard
|
- OGP rich media parser merged with TwitterCard
|
||||||
- Configuration: `:instance, rewrite_policy` moved to `:mrf, policies`, `:instance, :mrf_transparency` moved to `:mrf, :transparency`, `:instance, :mrf_transparency_exclusions` moved to `:mrf, :transparency_exclusions`. Old config namespace is deprecated.
|
- Configuration: `:instance, rewrite_policy` moved to `:mrf, policies`, `:instance, :mrf_transparency` moved to `:mrf, :transparency`, `:instance, :mrf_transparency_exclusions` moved to `:mrf, :transparency_exclusions`. Old config namespace is deprecated.
|
||||||
- Configuration: `:media_proxy, whitelist` format changed to host with scheme (e.g. `http://example.com` instead of `example.com`). Domain format is deprecated.
|
- Configuration: `:media_proxy, whitelist` format changed to host with scheme (e.g. `http://example.com` instead of `example.com`). Domain format is deprecated.
|
||||||
|
- **Breaking:** Configuration: `:instance, welcome_user_nickname` moved to `:welcome, :direct_message, :sender_nickname`, `:instance, :welcome_message` moved to `:welcome, :direct_message, :message`. Old config namespace is deprecated.
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>API Changes</summary>
|
<summary>API Changes</summary>
|
||||||
|
|
|
@ -17,6 +17,7 @@ defmodule VerifyError, do: defexception([:message])
|
||||||
def verify! do
|
def verify! do
|
||||||
:ok
|
:ok
|
||||||
|> check_migrations_applied!()
|
|> check_migrations_applied!()
|
||||||
|
|> check_welcome_message_config!()
|
||||||
|> check_rum!()
|
|> check_rum!()
|
||||||
|> handle_result()
|
|> handle_result()
|
||||||
end
|
end
|
||||||
|
@ -24,6 +25,22 @@ def verify! do
|
||||||
defp handle_result(:ok), do: :ok
|
defp handle_result(:ok), do: :ok
|
||||||
defp handle_result({:error, message}), do: raise(VerifyError, message: message)
|
defp handle_result({:error, message}), do: raise(VerifyError, message: message)
|
||||||
|
|
||||||
|
defp check_welcome_message_config!(:ok) do
|
||||||
|
if Pleroma.Config.get([:welcome, :email, :enabled], false) and
|
||||||
|
not Pleroma.Emails.Mailer.enabled?() do
|
||||||
|
Logger.error("""
|
||||||
|
To send welcome email do you need to enable mail.
|
||||||
|
\nconfig :pleroma, Pleroma.Emails.Mailer, enabled: true
|
||||||
|
""")
|
||||||
|
|
||||||
|
{:error, "The mail disabled."}
|
||||||
|
else
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp check_welcome_message_config!(result), do: result
|
||||||
|
|
||||||
# Checks for pending migrations.
|
# Checks for pending migrations.
|
||||||
#
|
#
|
||||||
def check_migrations_applied!(:ok) do
|
def check_migrations_applied!(:ok) do
|
||||||
|
|
|
@ -55,6 +55,24 @@ def warn do
|
||||||
mrf_user_allowlist()
|
mrf_user_allowlist()
|
||||||
check_old_mrf_config()
|
check_old_mrf_config()
|
||||||
check_media_proxy_whitelist_config()
|
check_media_proxy_whitelist_config()
|
||||||
|
check_welcome_message_config()
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_welcome_message_config do
|
||||||
|
instance_config = Pleroma.Config.get([:instance])
|
||||||
|
|
||||||
|
use_old_config =
|
||||||
|
Keyword.has_key?(instance_config, :welcome_user_nickname) or
|
||||||
|
Keyword.has_key?(instance_config, :welcome_message)
|
||||||
|
|
||||||
|
if use_old_config do
|
||||||
|
Logger.error("""
|
||||||
|
!!!DEPRECATION WARNING!!!
|
||||||
|
Your config is using old namespaces for Welcome messages configuration. You are need to change to new namespaces:
|
||||||
|
\n* `config :pleroma, :instance, welcome_user_nickname` is now `config :pleroma, :welcome, :direct_message, :sender_nickname`
|
||||||
|
\n* `config :pleroma, :instance, welcome_message` is now `config :pleroma, :welcome, :direct_message, :message`
|
||||||
|
""")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_old_mrf_config do
|
def check_old_mrf_config do
|
||||||
|
|
|
@ -737,6 +737,7 @@ def send_welcome_email(%User{email: email} = user) when is_binary(email) do
|
||||||
{:ok, :noop}
|
{:ok, :noop}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_welcome_email(_), do: {:ok, :noop}
|
def send_welcome_email(_), do: {:ok, :noop}
|
||||||
|
|
||||||
def try_send_confirmation_email(%User{} = user) do
|
def try_send_confirmation_email(%User{} = user) do
|
||||||
|
|
|
@ -9,6 +9,20 @@ defmodule Pleroma.ApplicationRequirementsTest do
|
||||||
|
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
|
|
||||||
|
describe "check_welcome_message_config!/1" do
|
||||||
|
setup do: clear_config([:welcome])
|
||||||
|
setup do: clear_config([Pleroma.Emails.Mailer])
|
||||||
|
|
||||||
|
test "raises if welcome email enabled but mail disabled" do
|
||||||
|
Pleroma.Config.put([:welcome, :email, :enabled], true)
|
||||||
|
Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false)
|
||||||
|
|
||||||
|
assert_raise Pleroma.ApplicationRequirements.VerifyError, "The mail disabled.", fn ->
|
||||||
|
capture_log(&Pleroma.ApplicationRequirements.verify!/0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "check_rum!" do
|
describe "check_rum!" do
|
||||||
setup_with_mocks([
|
setup_with_mocks([
|
||||||
{Pleroma.ApplicationRequirements, [:passthrough],
|
{Pleroma.ApplicationRequirements, [:passthrough],
|
||||||
|
|
Loading…
Reference in a new issue