Added backend for resetting setting values

This commit is contained in:
CasVT
2025-05-17 19:59:00 +02:00
parent fff78b83d4
commit 39847f18cd
4 changed files with 71 additions and 18 deletions

View File

@@ -530,6 +530,7 @@ def api_admin_settings(inputs: Dict[str, Any]):
hosting_changes = any(
inputs[s] is not None
and inputs[s] != getattr(settings.sv, s)
for s in ('host', 'port', 'url_prefix')
)
@@ -547,6 +548,24 @@ def api_admin_settings(inputs: Dict[str, Any]):
return return_api({})
elif request.method == 'DELETE':
hosting_changes = any(
s in inputs["setting_keys"]
and settings.get_default_value(s) != getattr(settings.sv, s)
for s in ('host', 'port', 'url_prefix')
)
if hosting_changes:
settings.backup_hosting_settings()
for setting in inputs["setting_keys"]:
settings.reset(setting)
if hosting_changes:
Server().restart(StartType.RESTART_HOSTING_CHANGES)
return return_api({})
@admin_api.route('/logs', LogfileData)
@endpoint_wrapper