From 4ec94696febc1a0513889b7dfe3d0f2b935e8571 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 0a642f50b2..27e5eb31db 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 0d0a6c7132..ca0703ca22 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(); });