v0.3.34: 每日汇报增加推送通道选择UI
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import { getDb } from '../database/database';
|
||||
import { getSystemConfig } from '../admin/system-config.service';
|
||||
import { getCloudConfigs } from '../cloud/credential.service';
|
||||
import { notify } from '../cloud/notification.service';
|
||||
import { notify, getGlobalNotifyConfigs, sendToChannels } from '../cloud/notification.service';
|
||||
import { CLOUD_LABELS } from '../config/cloud-constants';
|
||||
|
||||
// ═══════════════════════════════════════════════
|
||||
@@ -19,6 +19,7 @@ export interface DailyReportConfig {
|
||||
includeSaves: boolean;
|
||||
includeStorage: boolean;
|
||||
includeUsers: boolean;
|
||||
channels?: string[]; // 指定推送通道,空=全部全局通道
|
||||
}
|
||||
|
||||
export interface DailyReport {
|
||||
@@ -53,6 +54,7 @@ export function getDailyReportConfig(): DailyReportConfig {
|
||||
includeSaves: parsed.includeSaves !== false,
|
||||
includeStorage: parsed.includeStorage !== false,
|
||||
includeUsers: parsed.includeUsers !== false,
|
||||
channels: parsed.channels || [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -286,7 +288,16 @@ export async function runDailyReportIfScheduled(): Promise<void> {
|
||||
cfg.includeUsers
|
||||
);
|
||||
|
||||
notify('CloudSearch 每日汇报', content, 'info');
|
||||
// 通道过滤:如果配置了 channels 则只发指定通道
|
||||
if (cfg.channels && cfg.channels.length > 0) {
|
||||
const allChannels = getGlobalNotifyConfigs();
|
||||
const filtered = allChannels.filter(c => cfg.channels!.includes(c.name));
|
||||
if (filtered.length > 0) {
|
||||
sendToChannels(filtered, 'CloudSearch 每日汇报', content, 'info').catch(() => {});
|
||||
}
|
||||
} else {
|
||||
notify('CloudSearch 每日汇报', content, 'info');
|
||||
}
|
||||
|
||||
// Record last run
|
||||
const { getDb } = require('../database/database');
|
||||
@@ -332,6 +343,15 @@ export async function sendTestDailyReport(): Promise<{ success: boolean; report:
|
||||
cfg.includeStorage,
|
||||
cfg.includeUsers
|
||||
);
|
||||
notify('CloudSearch 每日汇报 [测试]', content, 'info');
|
||||
const tcfg = getDailyReportConfig();
|
||||
if (tcfg.channels && tcfg.channels.length > 0) {
|
||||
const allChannels = getGlobalNotifyConfigs();
|
||||
const filtered = allChannels.filter(c => tcfg.channels!.includes(c.name));
|
||||
if (filtered.length > 0) {
|
||||
sendToChannels(filtered, 'CloudSearch 每日汇报 [测试]', content, 'info').catch(() => {});
|
||||
}
|
||||
} else {
|
||||
notify('CloudSearch 每日汇报 [测试]', content, 'info');
|
||||
}
|
||||
return { success: true, report };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user