Skip to content

Commit

Permalink
Revert "[FIX] 유저 탈퇴시 푸시서버 유저 삭제 연동" (#305)
Browse files Browse the repository at this point in the history
Revert "[FIX] 유저 탈퇴시 푸시서버 유저 삭제 연동 (#304)"

This reverts commit c6c96cd.
  • Loading branch information
jokj624 authored Jan 3, 2023
1 parent c6c96cd commit a07063d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
14 changes: 0 additions & 14 deletions functions/api/routes/auth/userDELETE.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const db = require('../../../db/db');
const { userDB } = require("../../../db");
const { getAuth } = require('firebase-admin/auth');
const { nanoid } = require("nanoid");
const { deletePushUser } = require('../../../lib/pushServerHandlers');

/**
* @route DELETE /auth/user
Expand All @@ -23,17 +22,13 @@ module.exports = async (req, res) => {

try {
client = await db.connect(req);

deleteUser = await userDB.getUser(client, userId); // DB에서 해당 유저 정보 받아 옴
} catch (error) {
functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`);
console.log(error);

const slackMessage = `[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl} ${req.user ? `uid:${req.user.userId}` : 'req.user 없음'} ${JSON.stringify(error)}`;
slackAPI.sendMessageToSlack(slackMessage, slackAPI.WEB_HOOK_ERROR_MONITORING);

client.release();

return res.status(statusCode.INTERNAL_SERVER_ERROR).send(util.fail(statusCode.INTERNAL_SERVER_ERROR, responseMessage.INTERNAL_SERVER_ERROR)); // DB 관련 에러 : 500 INTERNAL SERVER ERROR
}

Expand All @@ -42,12 +37,9 @@ module.exports = async (req, res) => {
} catch (error) {
functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`);
console.log(error);

const slackMessage = `[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl} ${req.user ? `uid:${req.user.userId}` : 'req.user 없음'} ${JSON.stringify(error)}`;
slackAPI.sendMessageToSlack(slackMessage, slackAPI.WEB_HOOK_ERROR_MONITORING);

client.release();

if (error.errorInfo.code === 'auth/user-not-found') {
return res.status(statusCode.NOT_FOUND).send(util.fail(statusCode.NOT_FOUND, responseMessage.NO_USER)); // Firebase Auth에 해당 유저 존재하지 않을 경우 : 404 NOT FOUND
} else {
Expand All @@ -58,12 +50,6 @@ module.exports = async (req, res) => {
try {
const randomString = `:${nanoid(10)}`;
await userDB.deleteUser(client, userId, randomString); // DB에서 해당 유저 삭제

const response = await deletePushUser(deleteUser.mongoUserId);
if (response.status != 204) {
return res.status(response.statusCode).send(util.fail(response.statusCode, response.statusText));
}

res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.DELETE_USER));
} catch (error) {
functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`);
Expand Down
10 changes: 1 addition & 9 deletions functions/lib/pushServerHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,4 @@ const modifyContentTitle = async (contentId, ogTitle) => {
return response;
}

const deletePushUser = async (mongoUserId) => {
const url = `${baseURL}user/${mongoUserId}`;

const response = await axios.delete(url);

return response;
}

module.exports = { createPushServerUser, createNotification, modifyNotificationTime, modifyFcmToken, deleteNotification, modifyContentTitle, deletePushUser }
module.exports = { createPushServerUser, createNotification, modifyNotificationTime, modifyFcmToken, deleteNotification, modifyContentTitle }

0 comments on commit a07063d

Please sign in to comment.