omg tests (#5232), and .create returns flag data now

This commit is contained in:
Julian Lam
2016-11-25 15:09:52 -05:00
parent 98a104564b
commit 9f7c4befea
3 changed files with 126 additions and 10 deletions

View File

@@ -25,7 +25,11 @@ modsController.flags.list = function (req, res, next) {
res.locals.cids = results.moderatedCids;
}
flags.list({}, function(err, flags) {
flags.list({}, function (err, flags) {
if (err) {
return next(err);
}
res.render('flags/list', {
flags: flags
});

View File

@@ -64,7 +64,7 @@ Flags.list = function (filters, callback) {
'icon:text': userObj['icon:text']
}
}));
})
});
}
], function (err, flagObj) {
if (err) {
@@ -110,6 +110,10 @@ Flags.create = function (type, id, uid, reason, callback) {
async.apply(Flags.exists, type, id, uid),
async.apply(Flags.targetExists, type, id)
], function (err, checks) {
if (err) {
return next(err);
}
if (checks[0]) {
return next(new Error('[[error:already-flagged]]'));
} else if (!checks[1]) {
@@ -132,15 +136,16 @@ Flags.create = function (type, id, uid, reason, callback) {
})),
async.apply(db.sortedSetAdd.bind(db), 'flags:datetime', Date.now(), flagId),
async.apply(db.setObjectField.bind(db), 'flagHash:flagId', [type, id, uid].join(':'), flagId)
], next);
}
], function (err) {
if (err) {
return callback(err);
}
], function (err, data) {
if (err) {
return next(err);
}
callback();
});
next(null, flagId);
});
},
async.apply(Flags.get)
], callback);
// if (!parseInt(uid, 10) || !reason) {
// return callback();
// }