File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
server-plugins/notification-resources/src Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -607,6 +607,8 @@ export async function createPushNotification (
607607 }
608608}
609609
610+ const errorMessages = [ 'expired' , 'Unregistered' , 'No such subscription' ]
611+
610612async function sendPushToSubscription (
611613 control : TriggerControl ,
612614 targetUser : Ref < Account > ,
@@ -617,9 +619,11 @@ async function sendPushToSubscription (
617619 await webpush . sendNotification ( subscription , JSON . stringify ( data ) )
618620 } catch ( err ) {
619621 control . ctx . info ( 'Cannot send push notification to' , { user : targetUser , err } )
620- if ( err instanceof WebPushError && err . body . includes ( 'expired' ) ) {
621- const tx = control . txFactory . createTxRemoveDoc ( subscription . _class , subscription . space , subscription . _id )
622- await control . apply ( control . ctx , [ tx ] )
622+ if ( err instanceof WebPushError ) {
623+ if ( errorMessages . some ( ( p ) => ( err as WebPushError ) . body . includes ( p ) ) ) {
624+ const tx = control . txFactory . createTxRemoveDoc ( subscription . _class , subscription . space , subscription . _id )
625+ await control . apply ( control . ctx , [ tx ] )
626+ }
623627 }
624628 }
625629}
You can’t perform that action at this time.
0 commit comments