Fix #1437 and some clean ups

This commit is contained in:
syuilo 2018-04-10 21:47:56 +09:00
parent 16b070b926
commit 4ec94696fe
2 changed files with 5 additions and 19 deletions

View file

@ -8,10 +8,6 @@ import create from '../../../../services/following/create';
/**
* Follow a user
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
const follower = user;

View file

@ -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<any>}
*/
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();
});
});