update: fix
This commit is contained in:
@@ -33,6 +33,7 @@ export class NotificationsService {
|
|||||||
const em = this.em.fork();
|
const em = this.em.fork();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
await em.begin();
|
||||||
const user = await em.findOne(User, { id: createNotificationDto.recipientId });
|
const user = await em.findOne(User, { id: createNotificationDto.recipientId });
|
||||||
if (!user) throw new NotFoundException(UserMessage.USER_NOT_FOUND);
|
if (!user) throw new NotFoundException(UserMessage.USER_NOT_FOUND);
|
||||||
const notification = em.create(Notification, {
|
const notification = em.create(Notification, {
|
||||||
@@ -41,7 +42,6 @@ export class NotificationsService {
|
|||||||
});
|
});
|
||||||
await em.persistAndFlush(notification);
|
await em.persistAndFlush(notification);
|
||||||
|
|
||||||
// Send push notification to all user devices if user has push tokens
|
|
||||||
if (user.pushTokens && user.pushTokens.length > 0) {
|
if (user.pushTokens && user.pushTokens.length > 0) {
|
||||||
await this.sendPushNotificationToUserDevices(user.id, user.pushTokens, {
|
await this.sendPushNotificationToUserDevices(user.id, user.pushTokens, {
|
||||||
title: createNotificationDto.title,
|
title: createNotificationDto.title,
|
||||||
|
|||||||
Reference in New Issue
Block a user