mass notifs working

This commit is contained in:
shafi54 2026-05-20 21:35:48 +05:30
parent 286e6aabcb
commit 0290c170bb
3 changed files with 7 additions and 8 deletions

View file

@ -81,9 +81,8 @@ export async function sendAdminNotification(data: {
try {
const [ticket] = await expo.sendPushNotificationsAsync([message]);
console.log(`Notification sent:`, ticket);
} catch (error) {
console.error(`Failed to send notification:`, error);
console.log(`Failed to send notification:`, error);
throw error;
}
}

View file

@ -2,12 +2,12 @@ import { sendAdminNotification } from '@/src/lib/notif-job'
import { handleOrderCancelled, handleOrderPlaced } from '@/src/lib/post-order-handler'
export const handleNotifQueue =async (batch: any) => {
console.log('notif batch,', {batch})
batch.messages.forEach(async (message: any) => {
for (const message of batch.messages || []) {
const body = message?.body
if (!body) {
console.log('notif_queue message received with empty body')
return
continue
}
if (body.name === 'send-admin-notification' && body.jobData?.token) {
@ -17,11 +17,11 @@ export const handleNotifQueue =async (batch: any) => {
body: body.jobData.body,
imageUrl: body.jobData.imageUrl ?? null,
})
return
continue
}
// console.log('notif_queue', body)
})
}
}
export const handleOrderPlacedQueue = async (batch: any) => {

View file

@ -233,7 +233,7 @@ export const userRouter = {
tokens = userTokens.map(t => t.token);
}
tokens = ['ExponentPushToken[w4KTsLKnnp8SbURdl5-Q6x]', 'ExponentPushToken[81Io9TG3Qg0s3N0V8L86T-]', 'ExponentPushToken[YJRSQmMUEUbaI2VCZLaoN_]', 'ExponentPushToken[LQZgYkFG_3CweaUbv0fBKJ]']
// tokens = ['ExponentPushToken[w4KTsLKnnp8SbURdl5-Q6x]', 'ExponentPushToken[81Io9TG3Qg0s3N0V8L86T-]', 'ExponentPushToken[YJRSQmMUEUbaI2VCZLaoN_]', 'ExponentPushToken[LQZgYkFG_3CweaUbv0fBKJ]']
// Queue one job per token
let queuedCount = 0;