mirror of
https://github.com/xtr-dev/payload-notifications.git
synced 2025-12-12 20:03:23 +00:00
Refactor: Simplify notifications plugin configuration, remove unused code, and improve channel handling
This commit is contained in:
@@ -151,8 +151,8 @@ export class WebPushManager {
|
||||
)
|
||||
|
||||
return results.map((result) =>
|
||||
result.status === 'fulfilled'
|
||||
? result.value
|
||||
result.status === 'fulfilled'
|
||||
? result.value
|
||||
: { success: false, error: result.reason }
|
||||
)
|
||||
}
|
||||
@@ -211,11 +211,20 @@ export class WebPushManager {
|
||||
p256dh: subscription.keys.p256dh,
|
||||
auth: subscription.keys.auth,
|
||||
userAgent,
|
||||
channels: channels || ['all'],
|
||||
channels,
|
||||
isActive: true,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
console.info({
|
||||
user: userId,
|
||||
endpoint: subscription.endpoint,
|
||||
p256dh: subscription.keys.p256dh,
|
||||
auth: subscription.keys.auth,
|
||||
userAgent,
|
||||
channels,
|
||||
isActive: true,
|
||||
})
|
||||
// Create new subscription
|
||||
await this.payload.create({
|
||||
collection: 'push-subscriptions',
|
||||
@@ -225,7 +234,7 @@ export class WebPushManager {
|
||||
p256dh: subscription.keys.p256dh,
|
||||
auth: subscription.keys.auth,
|
||||
userAgent,
|
||||
channels: channels || ['all'],
|
||||
channels,
|
||||
isActive: true,
|
||||
},
|
||||
})
|
||||
@@ -268,4 +277,4 @@ export class WebPushManager {
|
||||
public getVapidPublicKey(): string {
|
||||
return this.config.vapidPublicKey
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user