Skip to content

Commit

Permalink
Refactor: slack notification text update
Browse files Browse the repository at this point in the history
  • Loading branch information
kmc7468 committed Feb 25, 2024
1 parent c813c51 commit 45a326d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/modules/slackNotification.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { slackWebhookUrl: slackUrl } = require("../../loadenv");
const { nodeEnv, slackWebhookUrl: slackUrl } = require("../../loadenv");
const axios = require("axios");
const logger = require("../modules/logger");

const sendTextToReportChannel = (text) => {
if (!slackUrl.report) return;

const data = {
text,
text: nodeEnv === "production" ? text : `(${nodeEnv}) ${text}`, // Production 환경이 아닌 경우, 환경 이름을 붙여서 전송합니다.
};
const config = { "Content-Type": "application/json" };

Expand Down Expand Up @@ -34,11 +34,13 @@ const notifyReportToReportChannel = (reportUser, report) => {

const notifyRoomCreationAbuseToReportChannel = (
abusingUser,
abusingUserNickname,
{ from, to, time, maxPartLength }
) => {
sendTextToReportChannel(
`${abusingUser}님이 어뷰징이 의심되는 방을 생성하려고 시도했습니다.
`${abusingUserNickname}님이 어뷰징이 의심되는 방을 생성하려고 시도했습니다.
사용자 ID: ${abusingUser}
출발지: ${from}
도착지: ${to}
출발 시간: ${time}
Expand Down
1 change: 1 addition & 0 deletions src/services/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ const createTestHandler = async (req, res) => {
if (isAbusing) {
const user = await userModel.findById(req.userOid).lean();
notifyRoomCreationAbuseToReportChannel(
req.userOid,
user?.nickname ?? req.userOid,
req.body
);
Expand Down

0 comments on commit 45a326d

Please sign in to comment.