forked from FoundKeyGang/FoundKey
Fix semantic errors
This commit is contained in:
parent
138fa1454f
commit
427b3dcd73
4 changed files with 27 additions and 24 deletions
|
@ -11,9 +11,10 @@ export default async (ctx: Koa.Context) => {
|
||||||
ctx.set('Access-Control-Allow-Origin', config.url);
|
ctx.set('Access-Control-Allow-Origin', config.url);
|
||||||
ctx.set('Access-Control-Allow-Credentials', 'true');
|
ctx.set('Access-Control-Allow-Credentials', 'true');
|
||||||
|
|
||||||
const username = ctx.request.body['username'];
|
const body = ctx.request.body as any;
|
||||||
const password = ctx.request.body['password'];
|
const username = body['username'];
|
||||||
const token = ctx.request.body['token'];
|
const password = body['password'];
|
||||||
|
const token = body['token'];
|
||||||
|
|
||||||
if (typeof username != 'string') {
|
if (typeof username != 'string') {
|
||||||
ctx.status = 400;
|
ctx.status = 400;
|
||||||
|
@ -35,11 +36,11 @@ export default async (ctx: Koa.Context) => {
|
||||||
usernameLower: username.toLowerCase(),
|
usernameLower: username.toLowerCase(),
|
||||||
host: null
|
host: null
|
||||||
}, {
|
}, {
|
||||||
fields: {
|
fields: {
|
||||||
data: false,
|
data: false,
|
||||||
profile: false
|
profile: false
|
||||||
}
|
}
|
||||||
}) as ILocalUser;
|
}) as ILocalUser;
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
ctx.throw(404, {
|
ctx.throw(404, {
|
||||||
|
|
|
@ -14,10 +14,12 @@ if (config.recaptcha) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (ctx: Koa.Context) => {
|
export default async (ctx: Koa.Context) => {
|
||||||
|
const body = ctx.request.body as any;
|
||||||
|
|
||||||
// Verify recaptcha
|
// Verify recaptcha
|
||||||
// ただしテスト時はこの機構は障害となるため無効にする
|
// ただしテスト時はこの機構は障害となるため無効にする
|
||||||
if (process.env.NODE_ENV !== 'test' && config.recaptcha != null) {
|
if (process.env.NODE_ENV !== 'test' && config.recaptcha != null) {
|
||||||
const success = await recaptcha(ctx.request.body['g-recaptcha-response']);
|
const success = await recaptcha(body['g-recaptcha-response']);
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
ctx.throw(400, 'recaptcha-failed');
|
ctx.throw(400, 'recaptcha-failed');
|
||||||
|
@ -25,8 +27,8 @@ export default async (ctx: Koa.Context) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const username = ctx.request.body['username'];
|
const username = body['username'];
|
||||||
const password = ctx.request.body['password'];
|
const password = body['password'];
|
||||||
|
|
||||||
// Validate username
|
// Validate username
|
||||||
if (!validateUsername(username)) {
|
if (!validateUsername(username)) {
|
||||||
|
@ -46,8 +48,8 @@ export default async (ctx: Koa.Context) => {
|
||||||
usernameLower: username.toLowerCase(),
|
usernameLower: username.toLowerCase(),
|
||||||
host: null
|
host: null
|
||||||
}, {
|
}, {
|
||||||
limit: 1
|
limit: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check username already used
|
// Check username already used
|
||||||
if (usernameExist !== 0) {
|
if (usernameExist !== 0) {
|
||||||
|
|
|
@ -181,10 +181,10 @@ router.get('/*/api/endpoints/*', async ctx => {
|
||||||
},
|
},
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
params: ep.meta.params ? sortParams(Object.entries(ep.meta.params).map(([k, v]) => parseParamDefinition(k, v))) : null,
|
params: ep.meta.params ? sortParams(Object.entries(ep.meta.params).map(([k, v]) => parseParamDefinition(k, v))) : null,
|
||||||
paramDefs: ep.meta.params ? extractParamDefRef(Object.entries(ep.meta.params).map(([k, v]) => v)) : null,
|
paramDefs: ep.meta.params ? extractParamDefRef(Object.values(ep.meta.params)) : null,
|
||||||
res: ep.meta.res,
|
res: ep.meta.res,
|
||||||
resProps: ep.meta.res && ep.meta.res.props ? sortParams(Object.entries(ep.meta.res.props).map(([k, v]) => parsePropDefinition(k, v))) : null,
|
resProps: ep.meta.res && ep.meta.res.props ? sortParams(Object.entries(ep.meta.res.props).map(([k, v]) => parsePropDefinition(k, v))) : null,
|
||||||
resDefs: null, //extractPropDefRef(Object.entries(ep.res.props).map(([k, v]) => parsePropDefinition(k, v)))
|
resDefs: null as any, //extractPropDefRef(Object.entries(ep.res.props).map(([k, v]) => parsePropDefinition(k, v)))
|
||||||
src: `https://github.com/syuilo/misskey/tree/master/src/server/api/endpoints/${name}.ts`
|
src: `https://github.com/syuilo/misskey/tree/master/src/server/api/endpoints/${name}.ts`
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -363,10 +363,10 @@ async function notifyToWatchersOfRenotee(renote: INote, user: IUser, nm: Notific
|
||||||
noteId: renote._id,
|
noteId: renote._id,
|
||||||
userId: { $ne: user._id }
|
userId: { $ne: user._id }
|
||||||
}, {
|
}, {
|
||||||
fields: {
|
fields: {
|
||||||
userId: true
|
userId: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watchers.forEach(watcher => {
|
watchers.forEach(watcher => {
|
||||||
nm.push(watcher.userId, type);
|
nm.push(watcher.userId, type);
|
||||||
|
@ -378,10 +378,10 @@ async function notifyToWatchersOfReplyee(reply: INote, user: IUser, nm: Notifica
|
||||||
noteId: reply._id,
|
noteId: reply._id,
|
||||||
userId: { $ne: user._id }
|
userId: { $ne: user._id }
|
||||||
}, {
|
}, {
|
||||||
fields: {
|
fields: {
|
||||||
userId: true
|
userId: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watchers.forEach(watcher => {
|
watchers.forEach(watcher => {
|
||||||
nm.push(watcher.userId, 'reply');
|
nm.push(watcher.userId, 'reply');
|
||||||
|
@ -432,7 +432,7 @@ async function publishToFollowers(note: INote, noteObj: any, user: IUser, noteAc
|
||||||
});
|
});
|
||||||
|
|
||||||
queue.forEach(inbox => {
|
queue.forEach(inbox => {
|
||||||
deliver(user, noteActivity, inbox);
|
deliver(user as any, noteActivity, inbox);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue