Skip to content

Commit

Permalink
Fix: push 알림전송 실패해도 다음 사람들에게 알림전송 하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
pp449 committed Sep 26, 2023
1 parent b40b375 commit 172863d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/apis/subscribe/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,23 @@ export const pushNotification = (major: string): Promise<number> => {
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);
}
});
Expand Down

0 comments on commit 172863d

Please sign in to comment.