Add notification system with admin UI and backend

Introduces a full notification system with support for Discord and Pushover backends, event triggers, and message formatting. Adds backend services, processors, and API endpoints for managing notifications, as well as a new Notifications tab in the admin settings UI. Updates documentation, database schema, and tests to cover notification features and approval workflow improvements. Also changes project license from MIT to AGPL v3.
This commit is contained in:
kikootwo
2026-01-21 15:28:23 -05:00
parent ac2ad8aac2
commit dc7e557694
51 changed files with 5065 additions and 264 deletions
+47 -1
View File
@@ -24,7 +24,8 @@ export type JobType =
| 'retry_missing_torrents'
| 'retry_failed_imports'
| 'cleanup_seeded_torrents'
| 'monitor_rss_feeds';
| 'monitor_rss_feeds'
| 'send_notification';
export interface JobPayload {
jobId?: string; // Database job ID (added automatically by addJob)
@@ -102,6 +103,16 @@ export interface CleanupSeededTorrentsPayload extends JobPayload {
scheduledJobId?: string;
}
export interface SendNotificationPayload extends JobPayload {
event: 'request_pending_approval' | 'request_approved' | 'request_available' | 'request_error';
requestId: string;
title: string;
author: string;
userName: string;
message?: string;
timestamp: Date;
}
export interface QueueStats {
waiting: number;
active: number;
@@ -298,6 +309,12 @@ export class JobQueueService {
const payloadWithJobId = await this.ensureJobRecord(job, 'cleanup_seeded_torrents');
return await processCleanupSeededTorrents(payloadWithJobId);
});
// Send notification processor
this.queue.process('send_notification', 5, async (job: BullJob<SendNotificationPayload>) => {
const { processSendNotification } = await import('../processors/send-notification.processor');
return await processSendNotification(job.data);
});
}
/**
@@ -790,6 +807,35 @@ export class JobQueueService {
this.redis.disconnect();
}
/**
* Add notification job
*/
async addNotificationJob(
event: 'request_pending_approval' | 'request_approved' | 'request_available' | 'request_error',
requestId: string,
title: string,
author: string,
userName: string,
message?: string
): Promise<string> {
logger.info(`Queueing notification: ${event}`, { requestId, title, userName });
return await this.addJob(
'send_notification',
{
event,
requestId,
title,
author,
userName,
message,
timestamp: new Date(),
} as SendNotificationPayload,
{
priority: 5, // Medium priority
}
);
}
/**
* Add a repeatable job with cron schedule
*/