0
0

Fix: notes/create hangs when rejected (#3221)

This commit is contained in:
MeiMei 2018-11-13 19:34:09 +09:00 committed by syuilo
parent adbe0fbcd1
commit 9f0b8ba2f8
3 changed files with 16 additions and 14 deletions

View File

@ -56,7 +56,7 @@ export default (endpoint: string, user: IUser, app: IApp, data: any, file?: any)
console.warn(`SLOW API CALL DETECTED: ${ep.name} (${time}ms)`);
}
} catch (e) {
if (e.name == 'INVALID_PARAM') {
if (e && e.name == 'INVALID_PARAM') {
rej({
code: e.name,
param: e.param,

View File

@ -216,7 +216,7 @@ export default define(meta, (ps, user, app) => new Promise(async (res, rej) => {
}
// 投稿を作成
const note = await create(user, {
create(user, {
createdAt: new Date(),
files: files,
poll: ps.poll,
@ -229,12 +229,14 @@ export default define(meta, (ps, user, app) => new Promise(async (res, rej) => {
visibility: ps.visibility,
visibleUsers,
geo: ps.geo
});
const noteObj = await pack(note, user);
// Reponse
})
.then(note => pack(note, user))
.then(noteObj => {
res({
createdNote: noteObj
});
})
.catch(e => {
rej(e);
});
}));

View File

@ -116,27 +116,27 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
// リプライ対象が削除された投稿だったらreject
if (data.reply && data.reply.deletedAt != null) {
return rej();
return rej('Reply target has been deleted');
}
// Renote対象が削除された投稿だったらreject
if (data.renote && data.renote.deletedAt != null) {
return rej();
return rej('Renote target has been deleted');
}
// Renote対象が「ホームまたは全体」以外の公開範囲ならreject
if (data.renote && data.renote.visibility != 'public' && data.renote.visibility != 'home') {
return rej();
return rej('Renote target is not public or home');
}
// リプライ対象が自分以外の非公開の投稿なら禁止
if (data.reply && data.reply.visibility == 'private' && !data.reply.userId.equals(user._id)) {
return rej();
return rej('Reply target is private of others');
}
// Renote対象が自分以外の非公開の投稿なら禁止
if (data.renote && data.renote.visibility == 'private' && !data.renote.userId.equals(user._id)) {
return rej();
return rej('Renote target is private of others');
}
if (data.text) {