removed deprecated dismiss methods

v1.18.x
Julian Lam 8 years ago
parent 20fa8ebf76
commit 0724bee6c6

@ -287,87 +287,6 @@ Flags.targetExists = function (type, id, callback) {
}
};
Flags.dismiss = function (pid, callback) {
async.waterfall([
function (next) {
db.getObjectFields('post:' + pid, ['pid', 'uid', 'flags'], next);
},
function (postData, next) {
if (!postData.pid) {
return callback();
}
async.parallel([
function (next) {
if (parseInt(postData.uid, 10)) {
if (parseInt(postData.flags, 10) > 0) {
async.parallel([
async.apply(db.sortedSetIncrBy, 'users:flags', -postData.flags, postData.uid),
async.apply(db.incrObjectFieldBy, 'user:' + postData.uid, 'flags', -postData.flags)
], next);
} else {
next();
}
} else {
next();
}
},
function (next) {
db.sortedSetsRemove([
'posts:flagged',
'posts:flags:count',
'uid:' + postData.uid + ':flag:pids'
], pid, next);
},
function (next) {
async.series([
function (next) {
db.getSortedSetRange('pid:' + pid + ':flag:uids', 0, -1, function (err, uids) {
if (err) {
return next(err);
}
async.each(uids, function (uid, next) {
var nid = 'post_flag:' + pid + ':uid:' + uid;
async.parallel([
async.apply(db.delete, 'notifications:' + nid),
async.apply(db.sortedSetRemove, 'notifications', 'post_flag:' + pid + ':uid:' + uid)
], next);
}, next);
});
},
async.apply(db.delete, 'pid:' + pid + ':flag:uids')
], next);
},
async.apply(db.deleteObjectField, 'post:' + pid, 'flags'),
async.apply(db.delete, 'pid:' + pid + ':flag:uid:reason'),
async.apply(db.deleteObjectFields, 'post:' + pid, ['flag:state', 'flag:assignee', 'flag:notes', 'flag:history'])
], next);
},
function (results, next) {
db.sortedSetsRemoveRangeByScore(['users:flags'], '-inf', 0, next);
}
], callback);
};
// Pretty sure we don't need this method...
Flags.dismissAll = function (callback) {
db.getSortedSetRange('posts:flagged', 0, -1, function (err, pids) {
if (err) {
return callback(err);
}
async.eachSeries(pids, Flags.dismiss, callback);
});
};
Flags.dismissByUid = function (uid, callback) {
db.getSortedSetRange('uid:' + uid + ':flag:pids', 0, -1, function (err, pids) {
if (err) {
return callback(err);
}
async.eachSeries(pids, Flags.dismiss, callback);
});
};
Flags.update = function (flagId, uid, changeset, callback) {
// Retrieve existing flag data to compare for history-saving purposes
var fields = ['state', 'assignee'];

Loading…
Cancel
Save