2018-11-01 19:32:24 +01:00
|
|
|
import $ from 'cafy'; import ID, { transform } from '../../../../../misc/cafy-id';
|
2018-06-01 17:15:17 +02:00
|
|
|
import rejectFollowRequest from '../../../../../services/following/requests/reject';
|
2018-11-02 05:47:44 +01:00
|
|
|
import User from '../../../../../models/user';
|
|
|
|
import define from '../../../define';
|
2018-06-01 14:55:27 +02:00
|
|
|
|
2018-07-16 21:36:44 +02:00
|
|
|
export const meta = {
|
|
|
|
desc: {
|
2018-08-28 23:59:43 +02:00
|
|
|
'ja-JP': '自分に届いた、指定したフォローリクエストを拒否します。',
|
|
|
|
'en-US': 'Reject a follow request.'
|
2018-07-16 21:36:44 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
requireCredential: true,
|
|
|
|
|
2018-11-01 19:32:24 +01:00
|
|
|
kind: 'following-write',
|
|
|
|
|
|
|
|
params: {
|
|
|
|
userId: {
|
|
|
|
validator: $.type(ID),
|
|
|
|
transform: transform,
|
|
|
|
}
|
|
|
|
}
|
2018-07-16 21:36:44 +02:00
|
|
|
};
|
|
|
|
|
2018-11-02 05:47:44 +01:00
|
|
|
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
2018-06-01 14:55:27 +02:00
|
|
|
// Fetch follower
|
|
|
|
const follower = await User.findOne({
|
2018-11-01 19:32:24 +01:00
|
|
|
_id: ps.userId
|
2018-06-01 14:55:27 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
if (follower === null) {
|
|
|
|
return rej('follower not found');
|
|
|
|
}
|
|
|
|
|
|
|
|
await rejectFollowRequest(user, follower);
|
|
|
|
|
|
|
|
res();
|
2018-11-02 05:47:44 +01:00
|
|
|
}));
|