mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
v3 adapt v2: lint client only shared ops and enable members integration tests
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
import i18n from '../i18n';
|
||||
import { NotFound } from '../libs/errors';
|
||||
import _ from 'lodash';
|
||||
|
||||
// TODO used only in client, move there?
|
||||
|
||||
module.exports = function(user, req, cb) {
|
||||
var i, ref, task;
|
||||
task = user.tasks[(ref = req.params) != null ? ref.id : void 0];
|
||||
module.exports = function deleteTask (user, req = {}) {
|
||||
let tid = _.get(req, 'params.id');
|
||||
let task = user.tasks[tid];
|
||||
|
||||
if (!task) {
|
||||
return typeof cb === "function" ? cb({
|
||||
code: 404,
|
||||
message: i18n.t('messageTaskNotFound', req.language)
|
||||
}) : void 0;
|
||||
throw new NotFound(i18n.t('messageTaskNotFound', req.language));
|
||||
}
|
||||
i = user[task.type + "s"].indexOf(task);
|
||||
if (~i) {
|
||||
user[task.type + "s"].splice(i, 1);
|
||||
|
||||
let index = user[`${task.type}s`].indexOf(task);
|
||||
if (index !== -1) {
|
||||
user[`${task.type}s`].splice(index, 1);
|
||||
}
|
||||
return typeof cb === "function" ? cb(null, {}) : void 0;
|
||||
|
||||
return {};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user