Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/TeamSparker/Spark-Server
Browse files Browse the repository at this point in the history
…into test
  • Loading branch information
youngkwon02 committed Nov 4, 2022
2 parents 9983dc8 + 2ba4f62 commit 06a575d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 33 deletions.
12 changes: 4 additions & 8 deletions functions/constants/alarmMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,17 @@ const FEED_LIKE = (who, roomName) => {
};

const REMIND_ALERT_NONE = (roomName) => {
const title = `🚨비상🚨`;
const body = `미완료 습관방 발견!👀 얼른 생명 지키러 가요!`;
// const title = `${roomName}방의 인증을 하지 않았어요!`;
// const body = `생명이 줄어들기 전에 서둘러 인증해주세요🏃‍♂️`;
const title = `${roomName}방의 인증을 하지 않았어요!`;
const body = `생명이 줄기 전에 서둘러 인증해주세요🏃‍♂️`;
const isService = true;
const category = 'remind';

return { title, body, isService, category };
};

const REMIND_ALERT_DONE = (roomName) => {
const title = `🚨비상🚨`;
const body = `미완료 습관방 발견!👀 얼른 생명 지키러 가요!`;
// const title = `${roomName}방에 인증을 안 한 친구가 있어요! `;
// const body = `지금 스파크를 보내 친구를 응원해주세요 🔥`;
const title = `${roomName}방 미인증 스파커 발견!`;
const body = `지금 스파크를 보내 친구를 응원해주세요🔥`;
const isService = true;
const category = 'remind';

Expand Down
37 changes: 12 additions & 25 deletions functions/scheduler/funcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,39 +176,26 @@ const sendRemind = async () => {
const today = now.format('YYYY-MM-DD');

const remindUsers = await recordDB.getPushRemindUsers(client, today);
const slackInfo = [];

if (remindUsers.length) {
const messages = [];

/**
* @임시_로직 (10시 리마인드 중복 알림 방지 / deviceToken DISTINCT 처리)
*/
const userIds = [];
const tokenGroups = _.groupBy(remindUsers, 'deviceToken');
const tokens = Object.keys(tokenGroups);
tokens.map((t) => {
const obj = tokenGroups[t][0];
userIds.push(obj.userId);
const { title, body, category } = alarmMessage.REMIND_ALERT_NONE(obj.roomName);
messages.push(pushAlarm.getMessage(title, body, t, category, null, obj.roomId));
remindUsers.map((u) => {
if (u.status == 'NONE' || u.status == 'CONSIDER') {
const { title, body, category } = alarmMessage.REMIND_ALERT_NONE(u.roomName);
messages.push(pushAlarm.getMessage(title, body, u.deviceToken, category, null, u.roomId));
slackInfo.push(`[X]${u.userId}(${u.roomId})`);
} else {
const { title, body, category } = alarmMessage.REMIND_ALERT_DONE(u.roomName);
messages.push(pushAlarm.getMessage(title, body, u.deviceToken, category, null, u.roomId));
slackInfo.push(`[O]${u.userId}(${u.roomId})`);
}
});

/**
* @실제_로직
*/
// remindUsers.map((u) => {
// if (u.status == 'NONE' || u.status == 'CONSIDER') {
// const { title, body, category } = alarmMessage.REMIND_ALERT_NONE(u.roomName);
// messages.push(pushAlarm.getMessage(title, body, u.deviceToken, category, null, u.roomId));
// } else {
// const { title, body, category } = alarmMessage.REMIND_ALERT_DONE(u.roomName);
// messages.push(pushAlarm.getMessage(title, body, u.deviceToken, category, null, u.roomId));
// }
// });

pushAlarm.sendMessages(null, null, messages);

const slackMessage = `[REMIND SEND SUCCESS]: To ${tokens.length} users: ${userIds.sort()}`;
const slackMessage = `[REMIND SEND SUCCESS]: To ${slackInfo.length} users \n${slackInfo}`;
slackAPI.sendMessageToSlack(slackMessage, slackAPI.DEV_WEB_HOOK_ERROR_MONITORING);
return;
}
Expand Down

0 comments on commit 06a575d

Please sign in to comment.