mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
interim commit to thread options
This commit is contained in:
@@ -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));
|
||||
Reference in New Issue
Block a user