From e1ff2961e60039748d664b43ea849dc0c59c3ee8 Mon Sep 17 00:00:00 2001 From: Nathan Lamy Date: Thu, 21 Aug 2025 12:21:45 +0200 Subject: [PATCH] fix: notificationclick event --- app/services/notification_service.ts | 8 +++----- start/routes.ts | 13 +++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/services/notification_service.ts b/app/services/notification_service.ts index 04f03f9..bd51900 100644 --- a/app/services/notification_service.ts +++ b/app/services/notification_service.ts @@ -5,7 +5,7 @@ import { DateTime } from 'luxon' import { UAParser } from 'ua-parser-js' import webpush, { PushSubscription } from 'web-push' -const MAX_FAILED_ATTEMPTS = 5 +const MAX_FAILED_ATTEMPTS = 1 export const EVENTS = { SYSTEM: 1 << 0, @@ -41,10 +41,8 @@ export class NotificationService { } private pushNotification(subscription: PushSubscription, payload: Record) { - return webpush.sendNotification(subscription, JSON.stringify(payload)).catch((err) => { - console.error('Error sending notification:', err) - return false - }) + console.log(payload) + return webpush.sendNotification(subscription, JSON.stringify(payload)) } public async sendNotification(notificationId: NotificationId, colle: Colle, args?: any) { diff --git a/start/routes.ts b/start/routes.ts index abfc8b2..acf1b36 100644 --- a/start/routes.ts +++ b/start/routes.ts @@ -12,6 +12,7 @@ import router from '@adonisjs/core/services/router' import { authThrottle } from './limiters.js' import { throttle } from './limiter.js' import { middleware } from './kernel.js' +import redis from '@adonisjs/redis/services/main' // TODO: Magic link login // transmit.registerRoutes() @@ -71,3 +72,15 @@ router }) .prefix('/internals') // TODO: Token authentication + +router.get('/', async () => { + await redis.publish( + 'jobs_queue', + JSON.stringify({ + type: 1, // Fetch day colles + // Format DD/MM/YYYY + date: '06/06/2025', + class_name: 'MPSI 2', + }) + ) +})