Synchronize frontend plugin configuration

This commit is contained in:
2026-08-25 11:56:41 +00:00
parent 228f46c681
commit 009a29343e
2 changed files with 38 additions and 7 deletions
+23
View File
@@ -51,6 +51,19 @@ Set secure MariaDB passwords in `.env`. Then, set at least these values in
"provider": "hcaptcha",
"secret": "replace with your hCaptcha secret"
},
"plugins": [
"announcement",
"application",
"banner",
"challenge",
"division",
"downloads",
"economy",
"event",
"poll",
"route",
"task"
],
"external_plugins": ["client-config"]
}
```
@@ -68,6 +81,16 @@ Create an hCaptcha site for the public frontend domain. Set its secret in the
`captcha.secret` value. Set the related public site key as
`VITE_HCAPTCHA_SITEKEY` in the frontend deployment.
The upstream sample uses plural names for some built-in plugins, but the
backend expects the singular names shown above. This deployment configuration
enables all built-in plugins by default. Keep `client-config` separate in
`external_plugins`.
The deployment patch synchronizes the plugin list from `config/config.json` to
the stored frontend configuration when the backend starts. Other frontend
settings in MariaDB stay unchanged. Restart the backend after you enable or
disable a plugin.
## Start the deployment
```bash
+15 -7
View File
@@ -1,18 +1,26 @@
--- a/src/external_plugins/client-config.py
+++ b/src/external_plugins/client-config.py
@@ -17,0 +18,6 @@
+def normalize_client_config(config):
@@ -17,0 +18,7 @@
+def normalize_client_config(config, plugins):
+ if not config["api_host"].startswith(("http://", "https://")):
+ config["api_host"] = f"https://{config['api_host']}"
+ config["plugins"] = plugins
+ return config
+
+
@@ -24 +30 @@
@@ -24 +31 @@
- return json.loads(config)
+ return normalize_client_config(json.loads(config))
@@ -37 +43 @@
+ return normalize_client_config(json.loads(config), app.config.plugins)
@@ -37 +44 @@
- config = json.loads(t[0][0])
+ config = normalize_client_config(json.loads(t[0][0]))
@@ -298 +304 @@
+ config = normalize_client_config(json.loads(t[0][0]), app.config.plugins)
@@ -298 +305 @@
- "api_host": config["domain"],
+ "api_host": f"https://{config['domain']}",
@@ -306,0 +314,6 @@
+ else:
+ frontend_conf = json.loads(t[0][2])
+ if frontend_conf.get("plugins") != config["plugins"]:
+ frontend_conf["plugins"] = config["plugins"]
+ frontend_conf = convertQuotation(json.dumps(frontend_conf))
+ cur.execute(f"UPDATE settings SET sval = '{frontend_conf}' WHERE skey = 'client-config/meta'")