From 172863dfa97c95d26b407efb03243f987be89b04 Mon Sep 17 00:00:00 2001 From: Lee sang Yeop Date: Tue, 26 Sep 2023 15:35:53 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20push=20=EC=95=8C=EB=A6=BC=EC=A0=84?= =?UTF-8?q?=EC=86=A1=20=EC=8B=A4=ED=8C=A8=ED=95=B4=EB=8F=84=20=EB=8B=A4?= =?UTF-8?q?=EC=9D=8C=20=EC=82=AC=EB=9E=8C=EB=93=A4=EC=97=90=EA=B2=8C=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=EC=A0=84=EC=86=A1=20=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/subscribe/service.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/apis/subscribe/service.ts b/src/apis/subscribe/service.ts index 00bd63ef..497ac035 100644 --- a/src/apis/subscribe/service.ts +++ b/src/apis/subscribe/service.ts @@ -73,22 +73,23 @@ export const pushNotification = (major: string): Promise => { db.query(query, async (err: Error, res: SubscribeUser[]) => { if (err) console.error(err); - try { - const message: PushMessage = { - title: `${major} 알림`, - body: '새로운 공지가 추가됐어요', - icon: './icons/icon-192x192.png', - }; + const message: PushMessage = { + title: `${major} 알림`, + body: '새로운 공지가 추가됐어요', + icon: './icons/icon-192x192.png', + }; - for (const userInfo of res) { + for (const userInfo of res) { + try { await webpush.sendNotification( JSON.parse(userInfo.user), JSON.stringify(message), ); + } catch (error) { + notificationToSlack(error); } resolve(res.length); - } catch (error) { - notificationToSlack(error); + resolve(0); } });