deploy: sync server CloudSearch 0.5.6
This commit is contained in:
@@ -19,6 +19,8 @@ import { reconnectRedis, testRedisConnection } from '../middleware/cache';
|
||||
import { startQrLogin, getQrLoginStatus, cancelQrLogin } from '../cloud/qr-login.service';
|
||||
import { BaiduDriver } from '../cloud/drivers/baidu.driver';
|
||||
import { testProxyConnection } from '../utils/proxy-agent';
|
||||
import { mergeRedactedUpdate, redactSensitive } from '../utils/redact';
|
||||
import { mergeNotifySettingsUpdate, mergePushUserNotifyConfigUpdate, mergeSystemConfigEntriesUpdate } from './admin-config-helpers';
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -147,7 +149,7 @@ router.use('/admin', authMiddleware);
|
||||
router.get('/admin/cloud-configs', (_req: Request, res: Response) => {
|
||||
try {
|
||||
const configs = getCloudConfigs();
|
||||
res.json(configs);
|
||||
res.json(redactSensitive(configs));
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message || 'Failed to fetch cloud configs' });
|
||||
}
|
||||
@@ -182,7 +184,7 @@ router.post('/admin/cloud-configs', async (req: Request, res: Response) => {
|
||||
}
|
||||
}
|
||||
|
||||
res.json(saved);
|
||||
res.json(redactSensitive(saved));
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message || 'Failed to save cloud config' });
|
||||
}
|
||||
@@ -197,8 +199,9 @@ router.put('/admin/cloud-configs/:id', (req: Request, res: Response) => {
|
||||
res.status(404).json({ error: 'Cloud config not found' });
|
||||
return;
|
||||
}
|
||||
const saved = saveCloudConfig({ ...req.body, id });
|
||||
res.json(saved);
|
||||
const update = mergeRedactedUpdate(req.body, existing);
|
||||
const saved = saveCloudConfig({ ...update, id });
|
||||
res.json(redactSensitive(saved));
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message || 'Failed to update cloud config' });
|
||||
}
|
||||
@@ -368,7 +371,7 @@ router.get('/admin/save-records', (req: Request, res: Response) => {
|
||||
router.get('/admin/system-configs', (_req: Request, res: Response) => {
|
||||
try {
|
||||
const configs = getAllSystemConfigs();
|
||||
res.json(configs);
|
||||
res.json(redactSensitive(configs));
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message || 'Failed to get system configs' });
|
||||
}
|
||||
@@ -382,7 +385,8 @@ router.put('/admin/system-configs', (req: Request, res: Response) => {
|
||||
res.status(400).json({ error: 'entries array is required' });
|
||||
return;
|
||||
}
|
||||
updateSystemConfigs(entries);
|
||||
const mergedEntries = mergeSystemConfigEntriesUpdate(entries, getAllSystemConfigs());
|
||||
updateSystemConfigs(mergedEntries);
|
||||
res.json({ success: true });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message || 'Failed to update system configs' });
|
||||
@@ -479,7 +483,7 @@ router.get('/admin/db-status', async (_req: Request, res: Response) => {
|
||||
db_path: dbFile,
|
||||
...counts,
|
||||
redis_status,
|
||||
redis_url,
|
||||
redis_url: redis_url ? '***REDACTED***' : redis_url,
|
||||
});
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message || 'Failed to get DB status' });
|
||||
@@ -720,7 +724,7 @@ router.get('/admin/cloud-configs/:id/notify', (req: Request, res: Response) => {
|
||||
try {
|
||||
const id = parseInt(req.params.id as string);
|
||||
const settings = getConfigNotifySettingsJSON(id);
|
||||
res.json(settings);
|
||||
res.json(redactSensitive(settings));
|
||||
} catch (err: any) {
|
||||
res.status(400).json({ error: err.message || 'Failed to get notification settings' });
|
||||
}
|
||||
@@ -730,7 +734,8 @@ router.get('/admin/cloud-configs/:id/notify', (req: Request, res: Response) => {
|
||||
router.put('/admin/cloud-configs/:id/notify', (req: Request, res: Response) => {
|
||||
try {
|
||||
const id = parseInt(req.params.id as string);
|
||||
const settings = req.body;
|
||||
const existing = getConfigNotifySettingsJSON(id);
|
||||
const settings = mergeNotifySettingsUpdate(req.body, existing);
|
||||
saveConfigNotifySettings(id, settings);
|
||||
res.json({ success: true, message: 'Push config saved' });
|
||||
} catch (err: any) {
|
||||
@@ -764,7 +769,7 @@ router.get('/admin/notify/providers', (_req: Request, res: Response) => {
|
||||
router.get('/admin/notify/global-config', (_req, res) => {
|
||||
try {
|
||||
const cfg = getGlobalNotifyConfig();
|
||||
res.json(cfg);
|
||||
res.json(redactSensitive(cfg));
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message || 'Failed to get global config' });
|
||||
}
|
||||
@@ -778,7 +783,9 @@ router.put('/admin/notify/global-config', (req, res) => {
|
||||
res.status(400).json({ error: 'Invalid config object' });
|
||||
return;
|
||||
}
|
||||
updateSystemConfig('global_notify_config', JSON.stringify(cfg));
|
||||
const existing = getGlobalNotifyConfig();
|
||||
const merged = mergeNotifySettingsUpdate(cfg, existing);
|
||||
updateSystemConfig('global_notify_config', JSON.stringify(merged));
|
||||
res.json({ success: true });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message || 'Failed to save global config' });
|
||||
@@ -793,7 +800,7 @@ router.get('/admin/push-users', (_req: Request, res: Response) => {
|
||||
...u,
|
||||
notify_config: (() => { try { return JSON.parse(u.notify_config); } catch { return {}; } })(),
|
||||
}));
|
||||
res.json(parsed);
|
||||
res.json(redactSensitive(parsed));
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message || 'Failed to list push users' });
|
||||
}
|
||||
@@ -804,9 +811,11 @@ router.post('/admin/push-users', (req: Request, res: Response) => {
|
||||
try {
|
||||
const { account, notify_config } = req.body;
|
||||
if (!account) return res.status(400).json({ error: 'account is required' });
|
||||
const configStr = typeof notify_config === 'string' ? notify_config : JSON.stringify(notify_config || {});
|
||||
const existing = getAllPushUsers().find(u => u.account === account);
|
||||
const mergedConfig = mergePushUserNotifyConfigUpdate({ notify_config }, existing);
|
||||
const configStr = JSON.stringify(mergedConfig);
|
||||
const user = upsertPushUser(account, configStr);
|
||||
res.json({ ...user, notify_config: JSON.parse(user!.notify_config) });
|
||||
res.json(redactSensitive({ ...user, notify_config: JSON.parse(user!.notify_config) }));
|
||||
} catch (err: any) {
|
||||
res.status(400).json({ error: err.message || 'Failed to save push user' });
|
||||
}
|
||||
@@ -818,9 +827,11 @@ router.put('/admin/push-users/:id', (req: Request, res: Response) => {
|
||||
const id = parseInt(req.params.id as string);
|
||||
const { account, notify_config } = req.body;
|
||||
if (!account) return res.status(400).json({ error: 'account is required' });
|
||||
const configStr = typeof notify_config === 'string' ? notify_config : JSON.stringify(notify_config || {});
|
||||
const existing = getAllPushUsers().find(u => u.id === id);
|
||||
const mergedConfig = mergePushUserNotifyConfigUpdate({ notify_config }, existing);
|
||||
const configStr = JSON.stringify(mergedConfig);
|
||||
const user = updatePushUser(id, account, configStr);
|
||||
res.json({ ...user, notify_config: JSON.parse(user!.notify_config) });
|
||||
res.json(redactSensitive({ ...user, notify_config: JSON.parse(user!.notify_config) }));
|
||||
} catch (err: any) {
|
||||
res.status(400).json({ error: err.message || 'Failed to update push user' });
|
||||
}
|
||||
@@ -849,7 +860,7 @@ router.get('/admin/daily-report/config', (_req, res) => {
|
||||
try {
|
||||
const { getDailyReportConfig } = require('../services/daily-report.service');
|
||||
const cfg = getDailyReportConfig();
|
||||
res.json(cfg);
|
||||
res.json(redactSensitive(cfg));
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message || 'Failed to get daily report config' });
|
||||
}
|
||||
@@ -861,7 +872,7 @@ router.put('/admin/daily-report/config', (req, res) => {
|
||||
const { saveDailyReportConfig } = require('../services/daily-report.service');
|
||||
saveDailyReportConfig(req.body);
|
||||
const { getDailyReportConfig } = require('../services/daily-report.service');
|
||||
res.json(getDailyReportConfig());
|
||||
res.json(redactSensitive(getDailyReportConfig()));
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ error: err.message || 'Failed to save daily report config' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user