diff --git a/src/modules/notifications/services/notifications.service.ts b/src/modules/notifications/services/notifications.service.ts index 6cc211f..5a24c3e 100755 --- a/src/modules/notifications/services/notifications.service.ts +++ b/src/modules/notifications/services/notifications.service.ts @@ -33,6 +33,7 @@ export class NotificationsService { const em = this.em.fork(); try { + await em.begin(); const user = await em.findOne(User, { id: createNotificationDto.recipientId }); if (!user) throw new NotFoundException(UserMessage.USER_NOT_FOUND); const notification = em.create(Notification, { @@ -41,7 +42,6 @@ export class NotificationsService { }); await em.persistAndFlush(notification); - // Send push notification to all user devices if user has push tokens if (user.pushTokens && user.pushTokens.length > 0) { await this.sendPushNotificationToUserDevices(user.id, user.pushTokens, { title: createNotificationDto.title,