Files
Auto_Bangumi/webui/src/api/notification.ts
Estrella Pan 48bf570697 feat(notification): redesign system to support multiple providers
- Add NotificationProvider base class with send() and test() methods
- Add NotificationManager for handling multiple providers simultaneously
- Add new providers: Discord, Gotify, Pushover, generic Webhook
- Migrate existing providers (Telegram, Bark, Server Chan, WeChat Work) to new architecture
- Add API endpoints for testing providers (/notification/test, /notification/test-config)
- Auto-migrate legacy single-provider configs to new multi-provider format
- Update WebUI with card-based multi-provider settings UI
- Add test button for each provider in settings
- Generic webhook supports template variables: {{title}}, {{season}}, {{episode}}, {{poster_url}}

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:58:42 +01:00

52 lines
1.1 KiB
TypeScript

import type { NotificationProviderConfig, NotificationType } from '#/config';
import type { TupleToUnion } from '#/utils';
export interface TestProviderRequest {
provider_index: number;
}
export interface TestProviderConfigRequest {
type: TupleToUnion<NotificationType>;
enabled?: boolean;
token?: string;
chat_id?: string;
webhook_url?: string;
server_url?: string;
device_key?: string;
user_key?: string;
api_token?: string;
template?: string;
url?: string;
}
export interface TestResponse {
success: boolean;
message: string;
message_zh: string;
message_en: string;
}
export const apiNotification = {
/**
* Test a configured provider by index
*/
async testProvider(request: TestProviderRequest) {
const { data } = await axios.post<TestResponse>(
'api/v1/notification/test',
request
);
return { data };
},
/**
* Test an unsaved provider configuration
*/
async testProviderConfig(request: TestProviderConfigRequest) {
const { data } = await axios.post<TestResponse>(
'api/v1/notification/test-config',
request
);
return { data };
},
};