Merge branch 'fix/moderation-log-crashes' into 'release/2.0.0'
moderation log: fix improperly migrated data See merge request pleroma/pleroma!2277
This commit is contained in:
commit
80ca06227a
@ -392,24 +392,6 @@ defmodule Pleroma.ModerationLog do
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "activate",
|
||||
"subject" => user
|
||||
}
|
||||
})
|
||||
when is_map(user) do
|
||||
get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "activate",
|
||||
"subject" => [user]
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
@spec get_log_entry_message(ModerationLog) :: String.t()
|
||||
def get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "activate",
|
||||
"subject" => users
|
||||
}
|
||||
}) do
|
||||
@ -421,24 +403,6 @@ defmodule Pleroma.ModerationLog do
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "deactivate",
|
||||
"subject" => user
|
||||
}
|
||||
})
|
||||
when is_map(user) do
|
||||
get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "deactivate",
|
||||
"subject" => [user]
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
@spec get_log_entry_message(ModerationLog) :: String.t()
|
||||
def get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "deactivate",
|
||||
"subject" => users
|
||||
}
|
||||
}) do
|
||||
@ -478,26 +442,6 @@ defmodule Pleroma.ModerationLog do
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "grant",
|
||||
"subject" => user,
|
||||
"permission" => permission
|
||||
}
|
||||
})
|
||||
when is_map(user) do
|
||||
get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "grant",
|
||||
"subject" => [user],
|
||||
"permission" => permission
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
@spec get_log_entry_message(ModerationLog) :: String.t()
|
||||
def get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "grant",
|
||||
"subject" => users,
|
||||
"permission" => permission
|
||||
}
|
||||
@ -510,26 +454,6 @@ defmodule Pleroma.ModerationLog do
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "revoke",
|
||||
"subject" => user,
|
||||
"permission" => permission
|
||||
}
|
||||
})
|
||||
when is_map(user) do
|
||||
get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "revoke",
|
||||
"subject" => [user],
|
||||
"permission" => permission
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
@spec get_log_entry_message(ModerationLog) :: String.t()
|
||||
def get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "revoke",
|
||||
"subject" => users,
|
||||
"permission" => permission
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
defmodule Pleroma.Repo.Migrations.FixModerationLogSubjects do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
execute(
|
||||
"update moderation_log set data = safe_jsonb_set(data, '{subject}', safe_jsonb_set('[]'::jsonb, '{0}', data->'subject')) where jsonb_typeof(data->'subject') != 'array' and data->>'action' = ANY('{revoke,grant,activate,deactivate,delete}');"
|
||||
)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user