diff --git a/src/services/AuthService.ts b/src/services/AuthService.ts index c653157..fb75a4d 100644 --- a/src/services/AuthService.ts +++ b/src/services/AuthService.ts @@ -6,6 +6,8 @@ import { AuthResponseDto } from "../interfaces/auth/AuthResponseDto"; import { AuthLogoutDto } from "../interfaces/auth/AuthLogoutDto"; import exceptionMessage from "../modules/exceptionMessage"; import agenda from "../loaders/agenda"; +import pushMessage from "../modules/pushMessage"; +import * as admin from "firebase-admin"; const kakaoLogin = async (kakaoToken: string, fcmToken: string): Promise => { try { @@ -77,6 +79,50 @@ const kakaoLogin = async (kakaoToken: string, fcmToken: string): Promise { + admin + .messaging() + .sendMulticast(alarms) + .then(function (res: any) { + console.log("Sent message result: ", res); + }); + job.repeatEvery("24 hours").save(); + done(); + }); + agenda.start(); + + await agenda.cancel({ "data.userId": existUser._id }); + + agenda.schedule("today at " + pushTime + ampm + "", "push_" + `${existUser._id}`, { userId: existUser._id }); + } + return data; } catch (err) { console.log(err); @@ -154,6 +200,50 @@ const appleLogin = async (appleToken: string, fcmToken: string): Promise { + admin + .messaging() + .sendMulticast(alarms) + .then(function (res: any) { + console.log("Sent message result: ", res); + }); + job.repeatEvery("24 hours").save(); + done(); + }); + agenda.start(); + + await agenda.cancel({ "data.userId": existUser._id }); + + agenda.schedule("today at " + pushTime + ampm + "", "push_" + `${existUser._id}`, { userId: existUser._id }); + } + return data; } catch (err) { console.log(err);