From c3f3bd9d8056ef0c19931acdc62e373cf00b9117 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 10 Apr 2018 21:47:56 +0900 Subject: [PATCH] Fix #1437 and some clean ups --- src/server/api/endpoints/following/create.ts | 4 ---- src/server/api/endpoints/following/delete.ts | 20 +++++--------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/server/api/endpoints/following/create.ts b/src/server/api/endpoints/following/create.ts index 0a642f50b..27e5eb31d 100644 --- a/src/server/api/endpoints/following/create.ts +++ b/src/server/api/endpoints/following/create.ts @@ -8,10 +8,6 @@ import create from '../../../../services/following/create'; /** * Follow a user - * - * @param {any} params - * @param {any} user - * @return {Promise} */ module.exports = (params, user) => new Promise(async (res, rej) => { const follower = user; diff --git a/src/server/api/endpoints/following/delete.ts b/src/server/api/endpoints/following/delete.ts index 0d0a6c713..ca0703ca2 100644 --- a/src/server/api/endpoints/following/delete.ts +++ b/src/server/api/endpoints/following/delete.ts @@ -4,14 +4,10 @@ import $ from 'cafy'; import User from '../../../../models/user'; import Following from '../../../../models/following'; -import { createHttp } from '../../../../queue'; +import deleteFollowing from '../../../../services/following/delete'; /** * Unfollow a user - * - * @param {any} params - * @param {any} user - * @return {Promise} */ module.exports = (params, user) => new Promise(async (res, rej) => { const follower = user; @@ -49,15 +45,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => { return rej('already not following'); } - createHttp({ - type: 'unfollow', - id: exist._id - }).save(error => { - if (error) { - return rej('unfollow failed'); - } + // Delete following + deleteFollowing(follower, followee); - // Send response - res(); - }); + // Send response + res(); });