Fix #1437 and some clean ups
This commit is contained in:
parent
de1cc3dce5
commit
c3f3bd9d80
2 changed files with 5 additions and 19 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
// Send response
|
||||
res();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue