notification

This commit is contained in:
2025-12-12 16:45:53 +03:30
parent f57145edc2
commit 3c3e5797e5
13 changed files with 241 additions and 172 deletions
@@ -7,12 +7,12 @@ 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';
import { NotifTitleEnum } from '../interfaces/notification.interface';
export interface SendNotificationParams {
restaurantId: string;
userId?: string;
title: NotificationTitleEnum;
title: NotifTitleEnum;
content: string;
idempotencyKey?: string;
}
@@ -45,7 +45,7 @@ export class NotificationService {
}
// Generate idempotency key if not provided
const finalIdempotencyKey = idempotencyKey || `${restaurantId}-${title}-${Date.now()}`;
// const finalIdempotencyKey = idempotencyKey || `${restaurantId}-${title}-${Date.now()}`;
// Create notification record
const user = userId ? await this.em.findOne(User, { id: userId }) : undefined;
@@ -69,7 +69,7 @@ export class NotificationService {
userId,
title,
content,
idempotencyKey: finalIdempotencyKey,
// idempotencyKey: finalIdempotencyKey,
notificationId: notification.id,
notificationType: preference.notificationType,
};
@@ -126,11 +126,7 @@ export class NotificationService {
await this.em.removeAndFlush(notification as any);
}
async findByRestaurantAndType(
restaurantId: string,
title: NotificationTitleEnum,
limit = 50,
): Promise<Notification[]> {
async findByRestaurantAndType(restaurantId: string, title: NotifTitleEnum, limit = 50): Promise<Notification[]> {
return this.em.find(
Notification,
{