forked from FoundKeyGang/FoundKey
Fix #1437 and some clean ups
This commit is contained in:
parent
16b070b926
commit
4ec94696fe
2 changed files with 5 additions and 19 deletions
|
@ -8,10 +8,6 @@ import create from '../../../../services/following/create';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Follow a user
|
* Follow a user
|
||||||
*
|
|
||||||
* @param {any} params
|
|
||||||
* @param {any} user
|
|
||||||
* @return {Promise<any>}
|
|
||||||
*/
|
*/
|
||||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
const follower = user;
|
const follower = user;
|
||||||
|
|
|
@ -4,14 +4,10 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../../../models/user';
|
import User from '../../../../models/user';
|
||||||
import Following from '../../../../models/following';
|
import Following from '../../../../models/following';
|
||||||
import { createHttp } from '../../../../queue';
|
import deleteFollowing from '../../../../services/following/delete';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unfollow a user
|
* Unfollow a user
|
||||||
*
|
|
||||||
* @param {any} params
|
|
||||||
* @param {any} user
|
|
||||||
* @return {Promise<any>}
|
|
||||||
*/
|
*/
|
||||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
const follower = user;
|
const follower = user;
|
||||||
|
@ -49,15 +45,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
return rej('already not following');
|
return rej('already not following');
|
||||||
}
|
}
|
||||||
|
|
||||||
createHttp({
|
// Delete following
|
||||||
type: 'unfollow',
|
deleteFollowing(follower, followee);
|
||||||
id: exist._id
|
|
||||||
}).save(error => {
|
|
||||||
if (error) {
|
|
||||||
return rej('unfollow failed');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
res();
|
res();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue