summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2020-06-04 08:59:03 +0900
committerGitHub <noreply@github.com>2020-06-04 08:59:03 +0900
commit9c4a789a4e7c34602c132086e7d9b3e85dd5d06d (patch)
tree039f03a071372367e1268d2cfeda47983bad6c9f /src
parentfeat(client): 投稿フォームのボタンの説明を表示するように... (diff)
downloadsharkey-9c4a789a4e7c34602c132086e7d9b3e85dd5d06d.tar.gz
sharkey-9c4a789a4e7c34602c132086e7d9b3e85dd5d06d.tar.bz2
sharkey-9c4a789a4e7c34602c132086e7d9b3e85dd5d06d.zip
Use insert for creating Note (#6440)
Diffstat (limited to 'src')
-rw-r--r--src/services/note/create.ts15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/services/note/create.ts b/src/services/note/create.ts
index 60a62dcdff..7b5e6a92ba 100644
--- a/src/services/note/create.ts
+++ b/src/services/note/create.ts
@@ -433,30 +433,29 @@ async function insertNote(user: User, data: Option, tags: string[], emojis: stri
// 投稿を作成
try {
- let note: Note;
if (insert.hasPoll) {
// Start transaction
await getConnection().transaction(async transactionalEntityManager => {
- note = await transactionalEntityManager.save(insert);
+ await transactionalEntityManager.insert(Note, insert);
const poll = new Poll({
- noteId: note.id,
+ noteId: insert.id,
choices: data.poll!.choices,
expiresAt: data.poll!.expiresAt,
multiple: data.poll!.multiple,
votes: new Array(data.poll!.choices.length).fill(0),
- noteVisibility: note.visibility,
+ noteVisibility: insert.visibility,
userId: user.id,
userHost: user.host
});
- await transactionalEntityManager.save(poll);
+ await transactionalEntityManager.insert(Poll, poll);
});
} else {
- note = await Notes.save(insert);
+ await Notes.insert(insert);
}
- return note!;
+ return await Notes.findOneOrFail(insert.id);
} catch (e) {
// duplicate key error
if (isDuplicateKeyValueError(e)) {
@@ -467,7 +466,7 @@ async function insertNote(user: User, data: Option, tags: string[], emojis: stri
console.error(e);
- throw new Error('something happened');
+ throw e;
}
}