mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
Merge branch 'fix-mrfs' into 'develop'
Added a Mix task "pleroma.config fix_mrf_policies" See merge request pleroma/pleroma!4177
This commit is contained in:
commit
683c4f0867
2 changed files with 30 additions and 0 deletions
1
changelog.d/fix-mrfs.add
Normal file
1
changelog.d/fix-mrfs.add
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Added a Mix task "pleroma.config fix_mrf_policies" which will remove erroneous MRF policies from ConfigDB
|
|
@ -205,6 +205,35 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Removes any policies that are not a real module
|
||||||
|
# as they will prevent the server from starting
|
||||||
|
def run(["fix_mrf_policies"]) do
|
||||||
|
check_configdb(fn ->
|
||||||
|
start_pleroma()
|
||||||
|
|
||||||
|
group = :pleroma
|
||||||
|
key = :mrf
|
||||||
|
|
||||||
|
%{value: value} =
|
||||||
|
group
|
||||||
|
|> ConfigDB.get_by_group_and_key(key)
|
||||||
|
|
||||||
|
policies =
|
||||||
|
Keyword.get(value, :policies, [])
|
||||||
|
|> Enum.filter(&is_atom(&1))
|
||||||
|
|> Enum.filter(fn mrf ->
|
||||||
|
case Code.ensure_compiled(mrf) do
|
||||||
|
{:module, _} -> true
|
||||||
|
{:error, _} -> false
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
value = Keyword.put(value, :policies, policies)
|
||||||
|
|
||||||
|
ConfigDB.update_or_create(%{group: group, key: key, value: value})
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
@spec migrate_to_db(Path.t() | nil) :: any()
|
@spec migrate_to_db(Path.t() | nil) :: any()
|
||||||
def migrate_to_db(file_path \\ nil) do
|
def migrate_to_db(file_path \\ nil) do
|
||||||
with :ok <- Pleroma.Config.DeprecationWarnings.warn() do
|
with :ok <- Pleroma.Config.DeprecationWarnings.warn() do
|
||||||
|
|
Loading…
Reference in a new issue