Skip to content

Commit

Permalink
feat(push-notifications): delete expired tokens for one-signal provid…
Browse files Browse the repository at this point in the history
…er (#1088)
  • Loading branch information
ChrisPdgn authored Jul 2, 2024
1 parent f82aa42 commit e88211f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '../interfaces/ISendNotification.js';
import { createConfiguration, DefaultApi, Notification } from '@onesignal/node-onesignal';
import ConduitGrpcSdk from '@conduitplatform/grpc-sdk';
import { NotificationToken } from '../models/index.js';

export class OneSignalProvider extends BaseNotificationProvider<IOneSignalSettings> {
private client?: DefaultApi;
Expand Down Expand Up @@ -42,7 +43,12 @@ export class OneSignalProvider extends BaseNotificationProvider<IOneSignalSettin
include_player_ids: Array.isArray(token) ? token : [token],
};
}
await this.client!.createNotification(notification);
const response = await this.client!.createNotification(notification);
if (response.errors?.invalid_player_ids?.length) {
await NotificationToken.getInstance().deleteMany({
token: { $in: response.errors.invalid_player_ids },
});
}
return;
}

Expand Down

0 comments on commit e88211f

Please sign in to comment.