fix: notificationclick event

This commit is contained in:
Nathan Lamy 2025-08-21 12:21:45 +02:00
parent 6213f3941c
commit e1ff2961e6
2 changed files with 16 additions and 5 deletions

View file

@ -5,7 +5,7 @@ import { DateTime } from 'luxon'
import { UAParser } from 'ua-parser-js' import { UAParser } from 'ua-parser-js'
import webpush, { PushSubscription } from 'web-push' import webpush, { PushSubscription } from 'web-push'
const MAX_FAILED_ATTEMPTS = 5 const MAX_FAILED_ATTEMPTS = 1
export const EVENTS = { export const EVENTS = {
SYSTEM: 1 << 0, SYSTEM: 1 << 0,
@ -41,10 +41,8 @@ export class NotificationService {
} }
private pushNotification(subscription: PushSubscription, payload: Record<string, any>) { private pushNotification(subscription: PushSubscription, payload: Record<string, any>) {
return webpush.sendNotification(subscription, JSON.stringify(payload)).catch((err) => { console.log(payload)
console.error('Error sending notification:', err) return webpush.sendNotification(subscription, JSON.stringify(payload))
return false
})
} }
public async sendNotification(notificationId: NotificationId, colle: Colle, args?: any) { public async sendNotification(notificationId: NotificationId, colle: Colle, args?: any) {

View file

@ -12,6 +12,7 @@ import router from '@adonisjs/core/services/router'
import { authThrottle } from './limiters.js' import { authThrottle } from './limiters.js'
import { throttle } from './limiter.js' import { throttle } from './limiter.js'
import { middleware } from './kernel.js' import { middleware } from './kernel.js'
import redis from '@adonisjs/redis/services/main'
// TODO: Magic link login // TODO: Magic link login
// transmit.registerRoutes() // transmit.registerRoutes()
@ -71,3 +72,15 @@ router
}) })
.prefix('/internals') .prefix('/internals')
// TODO: Token authentication // 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',
})
)
})