mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
Add config for Pleroma.Backup
This commit is contained in:
parent
a0ad9bd734
commit
3ad7492f9d
5 changed files with 31 additions and 2 deletions
|
@ -818,6 +818,10 @@ config :floki, :html_parser, Floki.HTMLParser.FastHtml
|
||||||
|
|
||||||
config :pleroma, Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.PleromaAuthenticator
|
config :pleroma, Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.PleromaAuthenticator
|
||||||
|
|
||||||
|
config :pleroma, Pleroma.Backup,
|
||||||
|
purge_after_days: 30,
|
||||||
|
limit_days: 7
|
||||||
|
|
||||||
# Import environment specific config. This must remain at the bottom
|
# Import environment specific config. This must remain at the bottom
|
||||||
# of this file so it overrides the configuration defined above.
|
# of this file so it overrides the configuration defined above.
|
||||||
import_config "#{Mix.env()}.exs"
|
import_config "#{Mix.env()}.exs"
|
||||||
|
|
|
@ -3712,5 +3712,25 @@ config :pleroma, :config_description, [
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
group: :pleroma,
|
||||||
|
key: Pleroma.Backup,
|
||||||
|
type: :group,
|
||||||
|
description: "Account Backup",
|
||||||
|
children: [
|
||||||
|
%{
|
||||||
|
key: :purge_after_days,
|
||||||
|
type: :integer,
|
||||||
|
description: "Remove backup achives after N days",
|
||||||
|
suggestions: [30]
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
key: :limit_days,
|
||||||
|
type: :integer,
|
||||||
|
description: "Limit user to export not more often than once per N days",
|
||||||
|
suggestions: [7]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1083,6 +1083,11 @@ Control favicons for instances.
|
||||||
|
|
||||||
* `enabled`: Allow/disallow displaying and getting instances favicons
|
* `enabled`: Allow/disallow displaying and getting instances favicons
|
||||||
|
|
||||||
|
## Account Backup
|
||||||
|
|
||||||
|
* `:purge_after_days` an integer, remove backup achives after N days.
|
||||||
|
* `:limit_days` an integer, limit user to export not more often than once per N days.
|
||||||
|
|
||||||
## Frontend management
|
## Frontend management
|
||||||
|
|
||||||
Frontends in Pleroma are swappable - you can specify which one to use here.
|
Frontends in Pleroma are swappable - you can specify which one to use here.
|
||||||
|
|
|
@ -49,7 +49,7 @@ defmodule Pleroma.Backup do
|
||||||
defp validate_limit(user) do
|
defp validate_limit(user) do
|
||||||
case get_last(user.id) do
|
case get_last(user.id) do
|
||||||
%__MODULE__{inserted_at: inserted_at} ->
|
%__MODULE__{inserted_at: inserted_at} ->
|
||||||
days = 7
|
days = Pleroma.Config.get([Pleroma.Backup, :limit_days])
|
||||||
diff = Timex.diff(NaiveDateTime.utc_now(), inserted_at, :days)
|
diff = Timex.diff(NaiveDateTime.utc_now(), inserted_at, :days)
|
||||||
|
|
||||||
if diff > days do
|
if diff > days do
|
||||||
|
|
|
@ -27,7 +27,7 @@ defmodule Pleroma.BackupTest do
|
||||||
|
|
||||||
test "it return an error if the export limit is over" do
|
test "it return an error if the export limit is over" do
|
||||||
%{id: user_id} = user = insert(:user)
|
%{id: user_id} = user = insert(:user)
|
||||||
limit_days = 7
|
limit_days = Pleroma.Config.get([Pleroma.Backup, :limit_days])
|
||||||
assert {:ok, %Oban.Job{args: args}} = Backup.create(user)
|
assert {:ok, %Oban.Job{args: args}} = Backup.create(user)
|
||||||
backup = Backup.get(args["backup_id"])
|
backup = Backup.get(args["backup_id"])
|
||||||
assert %Backup{user_id: ^user_id, processed: false, file_size: 0} = backup
|
assert %Backup{user_id: ^user_id, processed: false, file_size: 0} = backup
|
||||||
|
|
Loading…
Reference in a new issue