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

Revert "[FIX] 유저 탈퇴시 푸시서버 유저 삭제 연동" #305

Merged
merged 1 commit into from
Jan 3, 2023
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
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 }