wip #6441
This commit is contained in:
parent
41b491fa7c
commit
c4c20bee7c
28 changed files with 44 additions and 40 deletions
|
|
@ -18,17 +18,17 @@ export default async (user: User, note: Note, reaction?: string) => {
|
|||
// TODO: cache
|
||||
reaction = await toDbReaction(reaction, user.host);
|
||||
|
||||
let record: NoteReaction;
|
||||
let record: NoteReaction = {
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
noteId: note.id,
|
||||
userId: user.id,
|
||||
reaction
|
||||
};
|
||||
|
||||
// Create reaction
|
||||
try {
|
||||
record = await NoteReactions.save({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
noteId: note.id,
|
||||
userId: user.id,
|
||||
reaction
|
||||
});
|
||||
await NoteReactions.insert(record);
|
||||
} catch (e) {
|
||||
if (isDuplicateKeyValueError(e)) {
|
||||
record = await NoteReactions.findOneOrFail({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue