Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/constants/push.constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export const NOTIFICATION_MESSAGES = {
// 5. 친구 매칭 성공
FRIEND_MATCH_SUCCESS: {
TITLE: () => "마음이 딱 통했어요! ✨",
BODY: () => "새로운 친구와 연결되었습니다. 먼저 따뜻한 인사를 건네보는 건 어떨까요?",
BODY: ({ nickname }) => `${nickname}님과 새로운 친구가 되었습니다. 먼저 따뜻한 인사를 건네보는 건 어떨까요?`,
},
};
12 changes: 12 additions & 0 deletions src/services/friend.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import {
} from "../errors/base.error.js";
import { findMatchingSessionByParticipantUserId, updateMatchingSessionToFriends, updateMatchingSessionToDiscard } from "../repositories/session.repository.js";
import { SessionInternalError, SessionNotFoundError } from "../errors/session.error.js";
import { sendPushNotification } from "./push.service.js";
import { enqueueJob } from "../utils/queue.util.js";
import { pushQueue } from "../jobs/bootstraps/push.bootstrap.js";

async function userExistsOrThrow(userId) {
const userById = await findUserById(userId);
Expand Down Expand Up @@ -197,8 +200,17 @@ export const acceptFriendRequest = async (receiverUserId, requesterUserId) => {
receiverUserId,
requesterUserId,
});
const nickname = (await findUserById(receiverUserId)).nickname;
try {
const result = await acceptFriendRequestTx(receiverUserId, requesterUserId);
if (result) {
await enqueueJob(pushQueue, "PUSH_BY_FRIEND", {
userId: requesterUserId,
type: "FRIEND_MATCH_SUCCESS",
data: { nickname: nickname ?? `새 친구(${receiverUserId})` },
});
}
console.log("성공함");
return {
data: result,
};
Expand Down