1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-03 07:56:25 +02:00

Refactoring, Clean up and bug fixes

This commit is contained in:
syuilo
2018-11-02 03:32:24 +09:00
parent b4b9e76c8d
commit 931bdc6aac
108 changed files with 1722 additions and 1539 deletions

View File

@@ -1,6 +1,7 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
import Following from '../../../../models/following';
import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params';
export const meta = {
desc: {
@@ -10,20 +11,26 @@ export const meta = {
requireCredential: true,
kind: 'following-write'
kind: 'following-write',
params: {
userId: {
validator: $.type(ID),
transform: transform,
}
}
};
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const follower = user;
const [ps, psErr] = getParams(meta, params);
if (psErr) return rej(psErr);
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');
const follower = user;
// Fetch following
const following = await Following.findOne({
followerId: follower._id,
followeeId: userId
followeeId: ps.userId
});
if (following === null) {
@@ -37,7 +44,6 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
}
});
// Send response
res();
// TODO: イベント