summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/notes/reactions/create.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/api/endpoints/notes/reactions/create.ts')
-rw-r--r--src/server/api/endpoints/notes/reactions/create.ts17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/server/api/endpoints/notes/reactions/create.ts b/src/server/api/endpoints/notes/reactions/create.ts
index c80c5416b1..21757cb427 100644
--- a/src/server/api/endpoints/notes/reactions/create.ts
+++ b/src/server/api/endpoints/notes/reactions/create.ts
@@ -1,30 +1,21 @@
/**
* Module dependencies
*/
-import $ from 'cafy';
+import $ from 'cafy'; import ID from '../../../../../cafy-id';
import Note from '../../../../../models/note';
import create from '../../../../../services/note/reaction/create';
+import { validateReaction } from '../../../../../models/note-reaction';
/**
* React to a note
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
- const [noteId, noteIdErr] = $(params.noteId).id().$;
+ const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');
// Get 'reaction' parameter
- const [reaction, reactionErr] = $(params.reaction).string().or([
- 'like',
- 'love',
- 'laugh',
- 'hmm',
- 'surprise',
- 'congrats',
- 'angry',
- 'confused',
- 'pudding'
- ]).$;
+ const [reaction, reactionErr] = $.str.pipe(validateReaction.ok).get(params.reaction);
if (reactionErr) return rej('invalid reaction param');
// Fetch reactee