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)
36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import { Notifier, NotifyParams, NotifyResult, NotifierParam } from './notifier.types';
|
|
|
|
const params: NotifierParam[] = [
|
|
{ key: 'server', label: '服务器地址', type: 'url', required: true, placeholder: 'https://gotify.example.com' },
|
|
{ key: 'token', label: 'App Token', type: 'password', required: true, placeholder: 'Gotify App Token' },
|
|
{ key: 'title', label: '标题', type: 'text', default: 'CloudSearch', required: false },
|
|
{ key: 'content', label: '内容', type: 'text', required: true },
|
|
{ key: 'priority', label: '优先级', type: 'text', default: 5, required: false },
|
|
];
|
|
|
|
export const gotifyNotifier: Notifier = {
|
|
name: 'gotify',
|
|
label: 'Gotify',
|
|
params,
|
|
async notify(params) {
|
|
try {
|
|
const server = params.server.replace(/\/+$/, '');
|
|
const resp = await fetch(`${server}/message?token=${params.token}`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
title: params.title || 'CloudSearch',
|
|
message: params.content || '',
|
|
priority: params.priority || 5,
|
|
}),
|
|
});
|
|
if (resp.ok)
|
|
return { success: true, message: 'Gotify 推送成功' };
|
|
return { success: false, message: `HTTP ${resp.status}` };
|
|
}
|
|
catch (err: any) {
|
|
return { success: false, message: err.message };
|
|
}
|
|
},
|
|
};
|