do not throw error if failed to find tokens

This commit is contained in:
Hongbo Wu
2024-03-06 11:47:17 +08:00
parent bd237d06fa
commit c346ba8703

View File

@ -5,6 +5,7 @@ import { StatusType, User } from '../entity/user'
import { authTrx, getRepository, queryBuilderToRawSql } from '../repository'
import { userRepository } from '../repository/user'
import { SetClaimsRole } from '../utils/dictionary'
import { logger } from '../utils/logger'
import {
PushNotificationType,
sendMulticastPushNotifications,
@ -135,7 +136,8 @@ export const sendPushNotifications = async (
) => {
const tokens = await findDeviceTokensByUserId(userId)
if (tokens.length === 0) {
throw new Error('No device tokens found')
logger.info(`No device tokens found for user ${userId}`)
return
}
const message = {