mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-04 14:50:47 +01:00
check if category exists
This commit is contained in:
@@ -49,7 +49,7 @@ module.exports = function(SocketUser) {
|
||||
function (_oldUserData, next) {
|
||||
oldUserData = _oldUserData;
|
||||
if (!oldUserData || !oldUserData.username) {
|
||||
return next(new Error('[[error-invalid-data]]'));
|
||||
return next(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
if (parseInt(meta.config['username:disableEdit'], 10) === 1) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
var async = require('async');
|
||||
|
||||
var db = require('../database');
|
||||
var categories = require('../categories');
|
||||
|
||||
module.exports = function(User) {
|
||||
|
||||
@@ -34,13 +35,35 @@ module.exports = function(User) {
|
||||
if (!uid) {
|
||||
return callback();
|
||||
}
|
||||
db.sortedSetAdd('uid:' + uid + ':ignored:cids', Date.now(), cid, callback);
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
categories.exists(cid, next);
|
||||
},
|
||||
function (exists, next) {
|
||||
if (!exists) {
|
||||
return next(new Error('[[error:no-category]]'));
|
||||
}
|
||||
db.sortedSetAdd('uid:' + uid + ':ignored:cids', Date.now(), cid, next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
User.watchCategory = function(uid, cid, callback) {
|
||||
if (!uid) {
|
||||
return callback();
|
||||
}
|
||||
db.sortedSetRemove('uid:' + uid + ':ignored:cids', cid, callback);
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
categories.exists(cid, next);
|
||||
},
|
||||
function (exists, next) {
|
||||
if (!exists) {
|
||||
return next(new Error('[[error:no-category]]'));
|
||||
}
|
||||
db.sortedSetRemove('uid:' + uid + ':ignored:cids', cid, next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user