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:
39
source_clean/src/cloud/notifiers/lark.notifier.ts
Normal file
39
source_clean/src/cloud/notifiers/lark.notifier.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Notifier, NotifyParams, NotifyResult, NotifierParam } from './notifier.types';
|
||||
|
||||
const params: NotifierParam[] = [
|
||||
{ key: 'webhook_url', label: 'Webhook URL', type: 'url', required: true, placeholder: 'https://open.feishu.cn/open-apis/bot/v2/hook/xxx' },
|
||||
{ key: 'title', label: '\u6807\u9898', type: 'text', default: 'CloudSearch', required: false },
|
||||
{ key: 'content', label: '\u5185\u5bb9', type: 'text', required: true },
|
||||
{ key: 'level', label: '\u7ea7\u522b', type: 'text', default: 'info', required: false },
|
||||
];
|
||||
|
||||
export const larkNotifier: Notifier = {
|
||||
name: 'lark',
|
||||
label: '\u98de\u4e66/Lark',
|
||||
params,
|
||||
async notify(p: NotifyParams): Promise<NotifyResult> {
|
||||
try {
|
||||
const level = p.level || 'info';
|
||||
const template = level === 'error' ? 'red' : level === 'warn' ? 'orange' : 'blue';
|
||||
const resp = await fetch(p.webhook_url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
msg_type: 'interactive',
|
||||
card: {
|
||||
header: { title: { tag: 'plain_text', content: p.title || 'CloudSearch' }, template },
|
||||
elements: [
|
||||
{ tag: 'div', text: { tag: 'lark_md', content: p.content || '' } },
|
||||
{ tag: 'note', elements: [{ tag: 'plain_text', content: 'CloudSearch \u00b7 ' + new Date().toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' }) }] },
|
||||
],
|
||||
},
|
||||
}),
|
||||
});
|
||||
if (resp.ok) return { success: true, message: '\u98de\u4e66\u63a8\u9001\u6210\u529f' };
|
||||
const text = await resp.text();
|
||||
return { success: false, message: text.slice(0, 150) };
|
||||
} catch (err: any) {
|
||||
return { success: false, message: err.message };
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user