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 {