From 95df193e26f5df37f17238c46a2646c717c215b0 Mon Sep 17 00:00:00 2001 From: admin <362324317@qq.com> Date: Sun, 17 May 2026 16:41:46 +0800 Subject: [PATCH] =?UTF-8?q?v0.3.18:=20=E6=B6=88=E6=81=AF=E6=A8=A1=E7=89=88?= =?UTF-8?q?API=20+=20global-config=E7=AB=AF=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION | 2 +- source_clean/VERSION | 2 +- .../src/cloud/notification.service.ts | 6 +++++ source_clean/src/routes/admin.routes.ts | 27 ++++++++++++++++++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index ec96a62..8355eaf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.16 +0.3.18 diff --git a/source_clean/VERSION b/source_clean/VERSION index ec96a62..8355eaf 100644 --- a/source_clean/VERSION +++ b/source_clean/VERSION @@ -1 +1 @@ -0.3.16 +0.3.18 diff --git a/source_clean/src/cloud/notification.service.ts b/source_clean/src/cloud/notification.service.ts index 2c0638c..c2c0e40 100644 --- a/source_clean/src/cloud/notification.service.ts +++ b/source_clean/src/cloud/notification.service.ts @@ -18,6 +18,12 @@ export { getAllNotifiers, getNotifier, getAllNotifierParams }; let _globalChannelsCache: NotifyChannel[] | null = null; let _configHash = ''; +/** Returns the full global_notify_config JSON */ +export function getGlobalNotifyConfig(): Record { + const raw = getSystemConfig('global_notify_config') || '{}'; + try { return JSON.parse(raw); } catch { return {}; } +} + function getGlobalNotifyConfigs(): NotifyChannel[] { const raw = getSystemConfig('global_notify_config') || '{}'; let globalConfig: any = {}; diff --git a/source_clean/src/routes/admin.routes.ts b/source_clean/src/routes/admin.routes.ts index fc90cf0..c24623c 100644 --- a/source_clean/src/routes/admin.routes.ts +++ b/source_clean/src/routes/admin.routes.ts @@ -9,7 +9,7 @@ import { dailyCheckIn, skipCheckin, getCheckinSummary, getDrivesForCheckin } fro import { getAllCloudTypes } from '../cloud/cloud-types.service'; import { login, authMiddleware, verifyToken, changePassword } from '../admin/auth.service'; import { getAllPushUsers, upsertPushUser, updatePushUser, deletePushUser } from '../cloud/push-user.service'; -import { getAllNotifierParams, testChannel, saveConfigNotifySettings, getConfigNotifySettingsJSON } from '../cloud/notification.service'; +import { getAllNotifierParams, testChannel, saveConfigNotifySettings, getConfigNotifySettingsJSON, getGlobalNotifyConfig } from '../cloud/notification.service'; import { getStats } from '../admin/stats.service'; import { getAllSystemConfigs, updateSystemConfig, updateSystemConfigs, getSystemConfig } from '../admin/system-config.service'; import { getDb } from '../database/database'; @@ -718,6 +718,31 @@ router.get('/admin/notify/providers', (_req: Request, res: Response) => { } }); +/** GET /api/admin/notify/global-config */ +router.get('/admin/notify/global-config', (_req, res) => { + try { + const cfg = getGlobalNotifyConfig(); + res.json(cfg); + } catch (err: any) { + res.status(500).json({ error: err.message || 'Failed to get global config' }); + } +}); + +/** PUT /api/admin/notify/global-config */ +router.put('/admin/notify/global-config', (req, res) => { + try { + const cfg = req.body; + if (!cfg || typeof cfg !== 'object') { + res.status(400).json({ error: 'Invalid config object' }); + return; + } + updateSystemConfig('global_notify_config', JSON.stringify(cfg)); + res.json({ success: true }); + } catch (err: any) { + res.status(500).json({ error: err.message || 'Failed to save global config' }); + } +}); + /** GET /api/admin/push-users */ router.get('/admin/push-users', (_req: Request, res: Response) => { try {