notification module refactor

This commit is contained in:
2025-12-10 23:19:48 +03:30
parent 00d1c42331
commit 2d0c7dabee
16 changed files with 234 additions and 222 deletions
@@ -1,17 +1,18 @@
import { Injectable, Logger, NotFoundException } from '@nestjs/common';
import { EntityManager } from '@mikro-orm/postgresql';
import { Notification, NotificationTitle } from '../entities/notification.entity';
import { Notification } from '../entities/notification.entity';
import { NotificationPreferenceService } from './notification-preference.service';
import { NotificationQueueService } from './notification-queue.service';
import { NotificationQueueJob } from '../interfaces/notification-queue.interface';
import { Restaurant } from '../../restaurants/entities/restaurant.entity';
import { User } from '../../users/entities/user.entity';
import { NotificationType } from '../interfaces/notification.interface';
import { NotificationTitleEnum } from '../interfaces/notification.interface';
export interface SendNotificationParams {
restaurantId: string;
userId?: string;
title: NotificationTitle;
title: NotificationTitleEnum;
content: string;
idempotencyKey?: string;
}
@@ -53,7 +54,7 @@ export class NotificationService {
user,
title,
content,
idempotencyKey: finalIdempotencyKey,
// idempotencyKey: finalIdempotencyKey,
});
await this.em.persistAndFlush(notification);
@@ -125,7 +126,11 @@ export class NotificationService {
await this.em.removeAndFlush(notification as any);
}
async findByRestaurantAndType(restaurantId: string, title: NotificationTitle, limit = 50): Promise<Notification[]> {
async findByRestaurantAndType(
restaurantId: string,
title: NotificationTitleEnum,
limit = 50,
): Promise<Notification[]> {
return this.em.find(
Notification,
{