v0.3.5: restore full push notification system (14 channels)

Restored from v0.2.4:
- notifiers/: 14 push channels (bark/serverchan/telegram/lark/webhook/wechat/discord/smtp/...)
- push-user.service.ts: multi-user push config linked to cloud_configs.promotion_account
- notification.service.ts: full dispatcher with per-config + global fallback

New integrations:
- cloud.service.ts: notifyConfigEvent on save_success/cookie_expire/save_fail
- admin.routes.ts: 7 new API endpoints for push users, notify providers, channel test
- database.ts: migration for cloud_configs.notify_config column

How it works:
- Configure push channels in /admin/system-configs (global_notify_config JSON)
- Or per-cloud: link push_users.account = cloud_configs.promotion_account
- Notify events: save_success (green), cookie_expire (red), save_fail >=3 consecutive (yellow)
This commit is contained in:
2026-05-17 05:15:26 +08:00
parent 29e0fcbd43
commit 64b00661a2
22 changed files with 985 additions and 68 deletions

View File

@@ -0,0 +1,40 @@
import { Notifier, NotifyParams, NotifyResult, NotifierParam } from './notifier.types';
const params: NotifierParam[] = [
{ key: 'host', label: 'SMTP 服务器', type: 'text', required: true, placeholder: 'smtp.qq.com' },
{ key: 'port', label: '端口', type: 'text', default: 465, required: false },
{ key: 'secure', label: 'SSL', type: 'text', default: 'true', required: false },
{ key: 'user', label: '用户名', type: 'text', required: true, placeholder: 'user@example.com' },
{ key: 'pass', label: '密码/授权码', type: 'password', required: true, placeholder: 'SMTP 授权码' },
{ key: 'from', label: '发件人', type: 'text', required: true, placeholder: 'sender@example.com' },
{ key: 'to', label: '收件人', type: 'text', required: true, placeholder: 'receiver@example.com' },
{ key: 'title', label: '标题', type: 'text', default: 'CloudSearch', required: false },
{ key: 'content', label: '内容', type: 'text', required: true },
];
export const smtpNotifier: Notifier = {
name: 'smtp',
label: 'SMTP 邮件',
params,
async notify(params) {
try {
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
host: params.host,
port: params.port || 465,
secure: params.secure !== false,
auth: { user: params.user, pass: params.pass },
});
await transporter.sendMail({
from: params.from,
to: params.to,
subject: `[CloudSearch] ${params.title || ''}`,
text: params.content || '',
});
return { success: true, message: 'SMTP 邮件发送成功' };
}
catch (err: any) {
return { success: false, message: err.message };
}
},
};