mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
Tasks score notes (#8507)
* Added setting and modal for score notes * Added persistent score notes * Fixed linting issues and documented new field * Added max length to task score notes * Added check for score notes existence * Combined tasks perferences
This commit is contained in:
@@ -23,6 +23,8 @@ import Bluebird from 'bluebird';
|
||||
import _ from 'lodash';
|
||||
import logger from '../../libs/logger';
|
||||
|
||||
const MAX_SCORE_NOTES_LENGTH = 256;
|
||||
|
||||
/**
|
||||
* @apiDefine TaskNotFound
|
||||
* @apiError (404) {NotFound} TaskNotFound The specified task could not be found.
|
||||
@@ -482,6 +484,7 @@ api.updateTask = {
|
||||
*
|
||||
* @apiParam {String} taskId The task _id or alias
|
||||
* @apiParam {String="up","down"} direction The direction for scoring the task
|
||||
* @apiParam {String} scoreNotes Notes explaining the scoring
|
||||
*
|
||||
* @apiExample {json} Example call:
|
||||
* curl -X "POST" https://habitica.com/api/v3/tasks/test-api-params/score/up
|
||||
@@ -509,11 +512,15 @@ api.scoreTask = {
|
||||
if (validationErrors) throw validationErrors;
|
||||
|
||||
let user = res.locals.user;
|
||||
let scoreNotes = req.body.scoreNotes;
|
||||
if (scoreNotes && scoreNotes.length > MAX_SCORE_NOTES_LENGTH) throw new NotAuthorized(res.t('taskScoreNotesTooLong'));
|
||||
let {taskId} = req.params;
|
||||
|
||||
let task = await Tasks.Task.findByIdOrAlias(taskId, user._id, {userId: user._id});
|
||||
let direction = req.params.direction;
|
||||
|
||||
if (scoreNotes) task.scoreNotes = scoreNotes;
|
||||
|
||||
if (!task) throw new NotFound(res.t('taskNotFound'));
|
||||
|
||||
if (task.group.approval.required && !task.group.approval.approved) {
|
||||
|
||||
Reference in New Issue
Block a user