mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-10 03:17:51 +00:00
deprecation warning
changed namespace for activity expiration configuration
This commit is contained in:
parent
de4c935071
commit
629a8de9cb
4 changed files with 39 additions and 7 deletions
|
@ -2472,14 +2472,14 @@ config :pleroma, :config_description, [
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
group: :pleroma,
|
group: :pleroma,
|
||||||
key: Pleroma.ActivityExpiration,
|
key: Pleroma.Workers.PurgeExpiredActivity,
|
||||||
type: :group,
|
type: :group,
|
||||||
description: "Expired activity settings",
|
description: "Expired activities settings",
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :enabled,
|
key: :enabled,
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
description: "Whether expired activities will be sent to the job queue to be deleted"
|
description: "Enables expired activities addition & deletion"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
||||||
require Logger
|
require Logger
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
|
|
||||||
@type config_namespace() :: [atom()]
|
@type config_namespace() :: atom() | [atom()]
|
||||||
@type config_map() :: {config_namespace(), config_namespace(), String.t()}
|
@type config_map() :: {config_namespace(), config_namespace(), String.t()}
|
||||||
|
|
||||||
@mrf_config_map [
|
@mrf_config_map [
|
||||||
|
@ -57,6 +57,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
||||||
check_media_proxy_whitelist_config()
|
check_media_proxy_whitelist_config()
|
||||||
check_welcome_message_config()
|
check_welcome_message_config()
|
||||||
check_gun_pool_options()
|
check_gun_pool_options()
|
||||||
|
check_activity_expiration_config()
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_welcome_message_config do
|
def check_welcome_message_config do
|
||||||
|
@ -158,4 +159,20 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
||||||
Config.put(:pools, updated_config)
|
Config.put(:pools, updated_config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec check_activity_expiration_config() :: :ok | nil
|
||||||
|
def check_activity_expiration_config do
|
||||||
|
warning_preface = """
|
||||||
|
!!!DEPRECATION WARNING!!!
|
||||||
|
Your config is using old namespace for activity expiration configuration. Setting should work for now, but you are advised to change to new namespace to prevent possible issues later:
|
||||||
|
"""
|
||||||
|
|
||||||
|
move_namespace_and_warn(
|
||||||
|
[
|
||||||
|
{Pleroma.ActivityExpiration, Pleroma.Workers.PurgeExpiredActivity,
|
||||||
|
"\n* `config :pleroma, Pleroma.ActivityExpiration` is now `config :pleroma, Pleroma.Workers.PurgeExpiredActivity`"}
|
||||||
|
],
|
||||||
|
warning_preface
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,8 @@ defmodule Pleroma.Workers.PurgeExpiredActivity do
|
||||||
|
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
|
alias Pleroma.Activity
|
||||||
|
|
||||||
def enqueue(args) do
|
def enqueue(args) do
|
||||||
with true <- enabled?(),
|
with true <- enabled?(),
|
||||||
args when is_map(args) <- validate_expires_at(args) do
|
args when is_map(args) <- validate_expires_at(args) do
|
||||||
|
@ -20,7 +22,7 @@ defmodule Pleroma.Workers.PurgeExpiredActivity do
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def perform(%Oban.Job{args: %{"activity_id" => id}}) do
|
def perform(%Oban.Job{args: %{"activity_id" => id}}) do
|
||||||
with %Pleroma.Activity{} = activity <- find_activity(id),
|
with %Activity{} = activity <- find_activity(id),
|
||||||
%Pleroma.User{} = user <- find_user(activity.object.data["actor"]),
|
%Pleroma.User{} = user <- find_user(activity.object.data["actor"]),
|
||||||
false <- pinned_by_actor?(activity, user) do
|
false <- pinned_by_actor?(activity, user) do
|
||||||
Pleroma.Web.CommonAPI.delete(activity.id, user)
|
Pleroma.Web.CommonAPI.delete(activity.id, user)
|
||||||
|
@ -53,7 +55,7 @@ defmodule Pleroma.Workers.PurgeExpiredActivity do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp find_activity(id) do
|
defp find_activity(id) do
|
||||||
with nil <- Pleroma.Activity.get_by_id_with_object(id) do
|
with nil <- Activity.get_by_id_with_object(id) do
|
||||||
{:error, :activity_not_found}
|
{:error, :activity_not_found}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,7 +67,7 @@ defmodule Pleroma.Workers.PurgeExpiredActivity do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp pinned_by_actor?(activity, user) do
|
defp pinned_by_actor?(activity, user) do
|
||||||
with true <- Pleroma.Activity.pinned_by_actor?(activity, user) do
|
with true <- Activity.pinned_by_actor?(activity, user) do
|
||||||
:pinned_by_actor
|
:pinned_by_actor
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.RenameActivityExpirationSetting do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
config = Pleroma.ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.ActivityExpiration})
|
||||||
|
|
||||||
|
if config do
|
||||||
|
config
|
||||||
|
|> Ecto.Changeset.change(key: Pleroma.Workers.PurgeExpiredActivity)
|
||||||
|
|> Pleroma.Repo.update()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue