wip
This commit is contained in:
parent
73ac13a274
commit
e2461a9314
14 changed files with 122 additions and 242 deletions
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import * as mongo from 'mongodb';
|
||||
import it from '../../it';
|
||||
import User from '../../models/user';
|
||||
import Following from '../../models/following';
|
||||
import notify from '../../common/notify';
|
||||
|
|
@ -23,15 +23,8 @@ module.exports = (params, user) =>
|
|||
const follower = user;
|
||||
|
||||
// Get 'user_id' parameter
|
||||
let userId = params.user_id;
|
||||
if (userId === undefined || userId === null) {
|
||||
return rej('user_id is required');
|
||||
}
|
||||
|
||||
// Validate id
|
||||
if (!mongo.ObjectID.isValid(userId)) {
|
||||
return rej('incorrect user_id');
|
||||
}
|
||||
const [userId, userIdErr] = it(params.user_id, 'id', true);
|
||||
if (userIdErr) return rej('invalid user_id param');
|
||||
|
||||
// 自分自身
|
||||
if (user._id.equals(userId)) {
|
||||
|
|
@ -40,7 +33,7 @@ module.exports = (params, user) =>
|
|||
|
||||
// Get followee
|
||||
const followee = await User.findOne({
|
||||
_id: new mongo.ObjectID(userId)
|
||||
_id: userId
|
||||
}, {
|
||||
fields: {
|
||||
data: false,
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import * as mongo from 'mongodb';
|
||||
import it from '../../it';
|
||||
import User from '../../models/user';
|
||||
import Following from '../../models/following';
|
||||
import event from '../../event';
|
||||
|
|
@ -22,15 +22,8 @@ module.exports = (params, user) =>
|
|||
const follower = user;
|
||||
|
||||
// Get 'user_id' parameter
|
||||
let userId = params.user_id;
|
||||
if (userId === undefined || userId === null) {
|
||||
return rej('user_id is required');
|
||||
}
|
||||
|
||||
// Validate id
|
||||
if (!mongo.ObjectID.isValid(userId)) {
|
||||
return rej('incorrect user_id');
|
||||
}
|
||||
const [userId, userIdErr] = it(params.user_id, 'id', true);
|
||||
if (userIdErr) return rej('invalid user_id param');
|
||||
|
||||
// Check if the followee is yourself
|
||||
if (user._id.equals(userId)) {
|
||||
|
|
@ -39,7 +32,7 @@ module.exports = (params, user) =>
|
|||
|
||||
// Get followee
|
||||
const followee = await User.findOne({
|
||||
_id: new mongo.ObjectID(userId)
|
||||
_id: userId
|
||||
}, {
|
||||
fields: {
|
||||
data: false,
|
||||
Loading…
Add table
Add a link
Reference in a new issue