Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#524 접수된 신고 당사자에 FCM 발송 #525

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/modules/fcm.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,13 @@ const getTokensOfUsers = async (userIds, notificationOptions = {}) => {
* 주어진 token들에 메시지 알림을 전송합니다.
* TODO: 알림 전송 실패한 토큰 삭제하기
* @param {Array<string>} tokens - 메시지 알림을 받을 기기의 deviceToken들로 구성된 Array입니다.
* @param {string} type - 메시지 유형으로, "text" | "in" | "out" | "s3img" | "payment" | "settlement" 입니다.
* @param {string} title - 보낼 메시지의 제목입니다.
* @param {string} body - 보낼 메시지의 본문입니다.
* @param {string?} icon - 메시지를 보낸 사람의 프로필 사진 주소입니다.
* @param {string?} link - 메시지 알림 팝업을 클릭했을 때 이동할 주소입니다.
* @return {Promise<Number>} 메시지 알림 전송에 실패한 기기의 수를 반환합니다. 오류가 발생하면 -1을 반환합니다.
*/
const sendMessageByTokens = async (tokens, type, title, body, icon, link) => {
const sendMessageByTokens = async (tokens, title, body, icon, link) => {
if (tokens.length === 0) return -1;
try {
const message = {
Expand All @@ -201,7 +200,7 @@ const sendMessageByTokens = async (tokens, type, title, body, icon, link) => {
},
apns: { payload: { aps: { alert: { title, body } } } },
android: {
ttl: 0,
ttl: 3600,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😭

},
};
const { responses, failureCount } = await getMessaging().sendMulticast(
Expand Down
1 change: 0 additions & 1 deletion src/modules/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ const emitChatEvent = async (io, chat) => {
);
await sendMessageByTokens(
deviceTokensExceptAuthor,
type,
name,
getMessageBody(type, nickname, content),
profileImageUrl,
Expand Down
8 changes: 8 additions & 0 deletions src/services/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { sendReportEmail } = require("../modules/email");
const logger = require("../modules/logger");
const reportEmailPage = require("../views/reportEmailPage");
const { notifyReportToReportChannel } = require("../modules/slackNotification");
const { getTokensOfUsers, sendMessageByTokens } = require("../modules/fcm");

const createHandler = async (req, res) => {
try {
Expand Down Expand Up @@ -54,6 +55,13 @@ const createHandler = async (req, res) => {
emailRoomId
);
sendReportEmail(reported.email, report, emailHtml);
await sendMessageByTokens(
await getTokensOfUsers([req.userId]),
"신고가 접수되었습니다.",
"신고 내용을 확인해주세요.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

미정산 / 미탑승 / 기타 정도의 신고 사유는 알림 메세지에서 바로 확인할 수 있어도 좋을 것 같습니다!

"",
"/mypage?report=true",
);
}

res.status(200).send("User/report : report successful");
Expand Down
Loading