mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
wip: split shared ops
This commit is contained in:
20
common/script/ops/updateTask.js
Normal file
20
common/script/ops/updateTask.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import i18n from '../i18n';
|
||||
import _ from 'lodash';
|
||||
|
||||
module.exports = function (user, req, cb) {
|
||||
var ref, task;
|
||||
if (!(task = user.tasks[(ref = req.params) !== null ? ref.id : void 0])) {
|
||||
return typeof cb === 'function' ? cb({
|
||||
code: 404,
|
||||
message: i18n.t('messageTaskNotFound', req.language)
|
||||
}) : void 0;
|
||||
}
|
||||
_.merge(task, _.omit(req.body, ['checklist', 'id', 'type']));
|
||||
if (req.body.checklist) {
|
||||
task.checklist = req.body.checklist;
|
||||
}
|
||||
if (typeof task.markModified === 'function') {
|
||||
task.markModified('tags');
|
||||
}
|
||||
return typeof cb === 'function' ? cb(null, task) : void 0;
|
||||
};
|
||||
Reference in New Issue
Block a user