interim commit to thread options

This commit is contained in:
Julian Lam
2013-05-07 09:21:46 -04:00
parent d7c5a3c150
commit b2c6d4f7c7
7 changed files with 96 additions and 17 deletions

View File

@@ -1,7 +1,8 @@
var RDB = require('./redis.js'),
posts = require('./posts.js'),
utils = require('./utils.js'),
user = require('./user.js');
user = require('./user.js'),
configs = require('../config.js');
(function(Topics) {
@@ -135,8 +136,71 @@ var RDB = require('./redis.js'),
timeout: 2000
});
});
};
Topics.lock = function(tid, uid, socket) {
user.getUserField(uid, 'reputation', function(rep) {
if (rep >= configs.privilege_thresholds.manage_thread) {
// Mark thread as locked
RDB.set('tid:' + tid + ':locked', 1);
if (socket) {
socket.emit('event:topic_locked', {
tid: tid,
status: 'ok'
});
}
}
});
}
Topics.unlock = function(tid, uid, socket) {
user.getUserField(uid, 'reputation', function(rep) {
if (rep >= configs.privilege_thresholds.manage_thread) {
// Mark thread as locked
RDB.set('tid:' + tid + ':locked', 0);
if (socket) {
socket.emit('event:topic_unlocked', {
tid: tid,
status: 'ok'
});
}
}
});
}
Topics.delete = function(tid, uid, socket) {
user.getUserField(uid, 'reputation', function(rep) {
if (rep >= configs.privilege_thresholds.manage_thread) {
// Mark thread as deleted
RDB.set('tid:' + tid + ':deleted', 1);
Topics.lock(tid, uid);
if (socket) {
socket.emit('event:topic_deleted', {
tid: tid,
status: 'ok'
});
}
}
});
}
Topics.restore = function(tid, uid, socket) {
user.getUserField(uid, 'reputation', function(rep) {
if (rep >= configs.privilege_thresholds.manage_thread) {
// Mark thread as deleted
RDB.set('tid:' + tid + ':deleted', 0);
Topics.lock(tid, uid);
if (socket) {
socket.emit('event:topic_restored', {
tid: tid,
status: 'ok'
});
}
}
});
}
}(exports));