webupdate

This commit is contained in:
Local Server
2026-01-19 01:17:43 -06:00
parent 5b86f796d6
commit f8068ba54c
65 changed files with 2165 additions and 520 deletions

View File

@@ -891,12 +891,22 @@ const settingsHandler = (key) => ({
sendSuccess(res, { settings });
}),
post: asyncHandler(async (req, res) => {
const settings = req.body;
const newSettings = req.body;
// Get existing settings first and merge
const existingResult = await query(
"SELECT settings FROM site_settings WHERE key = $1",
[key],
);
const existingSettings =
existingResult.rows.length > 0 ? existingResult.rows[0].settings : {};
// Merge new settings with existing (new settings overwrite existing for same keys)
const mergedSettings = { ...existingSettings, ...newSettings };
await query(
`INSERT INTO site_settings (key, settings, updatedat)
VALUES ($1, $2, NOW())
ON CONFLICT (key) DO UPDATE SET settings = $2, updatedat = NOW()`,
[key, JSON.stringify(settings)],
[key, JSON.stringify(mergedSettings)],
);
sendSuccess(res, { message: `${key} settings saved successfully` });
}),