mirror of
https://github.com/docmost/docmost.git
synced 2026-06-11 02:36:56 +08:00
feat: notifications (#1947)
* feat: notifications * feat: watchers * improvements * handle page move for watchers * make watchers non-blocking * more
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user