feat: notifications (#1947)

* feat: notifications
* feat: watchers

* improvements

* handle page move for watchers

* make watchers non-blocking

* more
This commit is contained in:
Philip Okugbe
2026-02-14 20:00:38 -08:00
committed by GitHub
parent e0ab9d9b5e
commit 05b3c65b0f
80 changed files with 3071 additions and 238 deletions
@@ -5,4 +5,5 @@ export interface MailMessage {
text?: string;
html?: string;
template?: any;
notificationId?: string;
}
@@ -4,11 +4,15 @@ import { QueueName } from '../../queue/constants';
import { Job } from 'bullmq';
import { MailService } from '../mail.service';
import { MailMessage } from '../interfaces/mail.message';
import { NotificationRepo } from '@docmost/db/repos/notification/notification.repo';
@Processor(QueueName.EMAIL_QUEUE)
export class EmailProcessor extends WorkerHost implements OnModuleDestroy {
private readonly logger = new Logger(EmailProcessor.name);
constructor(private readonly mailService: MailService) {
constructor(
private readonly mailService: MailService,
private readonly notificationRepo: NotificationRepo,
) {
super();
}
@@ -18,6 +22,14 @@ export class EmailProcessor extends WorkerHost implements OnModuleDestroy {
} catch (err) {
throw err;
}
if (job.data.notificationId) {
try {
await this.notificationRepo.markAsEmailed(job.data.notificationId);
} catch (err) {
this.logger.warn(`Failed to mark notification ${job.data.notificationId} as emailed`);
}
}
}
@OnWorkerEvent('active')