From a71fcff41755dc35f55fcdc227a1536e129f61be Mon Sep 17 00:00:00 2001 From: Gian Lazzarini Date: Sat, 1 Jun 2024 12:27:28 -0700 Subject: [PATCH] wip --- src/notification/notification.service.ts | 37 ++++++++++++++---------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/notification/notification.service.ts b/src/notification/notification.service.ts index aace43e3..0e85235f 100644 --- a/src/notification/notification.service.ts +++ b/src/notification/notification.service.ts @@ -149,10 +149,28 @@ export class NotificationService { to: string, ) { this.logger.debug(this.sendPushNotification.name); - // const data = { - // notification, - // to, - // }; + const data = { + notification, + to, + }; + + const result = await this.httpService + .post(this.sendEndpoint, data, { + headers: { + Authorization: 'key=' + this.serverKey, + }, + }) + .toPromise() + .catch((e) => this.logger.debug(e)); + + return result; + } + + private async sendWebPushNotification( + notification: PushNotificationDto, + to: string, + ) { + this.logger.debug(this.sendWebPushNotification.name); webpush .sendNotification( subscription, @@ -168,16 +186,5 @@ export class NotificationService { .catch((error) => { console.log(error); }); - - // const result = await this.httpService - // .post(this.sendEndpoint, data, { - // headers: { - // Authorization: 'key=' + this.serverKey, - // }, - // }) - // .toPromise() - // .catch((e) => this.logger.debug(e)); - - // return result; } }