2756f553c6
* wip
* wip
* wip
* Update attached_notes.ts
* wip
* Refactor
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Update call.ts
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* ✌️
* Fix
51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
import $ from 'cafy';
|
|
import ID, { transform } from '../../../../../misc/cafy-id';
|
|
import rejectFollowRequest from '../../../../../services/following/requests/reject';
|
|
import User from '../../../../../models/user';
|
|
import define from '../../../define';
|
|
import { ApiError } from '../../../error';
|
|
|
|
export const meta = {
|
|
desc: {
|
|
'ja-JP': '自分に届いた、指定したフォローリクエストを拒否します。',
|
|
'en-US': 'Reject a follow request.'
|
|
},
|
|
|
|
requireCredential: true,
|
|
|
|
kind: 'following-write',
|
|
|
|
params: {
|
|
userId: {
|
|
validator: $.type(ID),
|
|
transform: transform,
|
|
desc: {
|
|
'ja-JP': '対象のユーザーのID',
|
|
'en-US': 'Target user ID'
|
|
}
|
|
}
|
|
},
|
|
|
|
errors: {
|
|
noSuchUser: {
|
|
message: 'No such user.',
|
|
code: 'NO_SUCH_USER',
|
|
id: 'abc2ffa6-25b2-4380-ba99-321ff3a94555'
|
|
},
|
|
}
|
|
};
|
|
|
|
export default define(meta, async (ps, user) => {
|
|
// Fetch follower
|
|
const follower = await User.findOne({
|
|
_id: ps.userId
|
|
});
|
|
|
|
if (follower === null) {
|
|
throw new ApiError(meta.errors.noSuchUser);
|
|
}
|
|
|
|
await rejectFollowRequest(user, follower);
|
|
|
|
return;
|
|
});
|