v0.3.18: 消息模版API + global-config端点

This commit is contained in:
2026-05-17 16:41:46 +08:00
parent ad186431dd
commit 95df193e26
4 changed files with 34 additions and 3 deletions

View File

@@ -1 +1 @@
0.3.16
0.3.18

View File

@@ -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<string, any> {
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 = {};

View File

@@ -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 {