thread pinning

This commit is contained in:
Julian Lam
2013-05-07 15:14:47 -04:00
parent ae43a299df
commit bf7c602cd8
3 changed files with 83 additions and 8 deletions

View File

@@ -215,4 +215,36 @@ var RDB = require('./redis.js'),
}
});
}
Topics.pin = 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 + ':pinned', 1);
if (socket) {
io.sockets.in('topic_' + tid).emit('event:topic_pinned', {
tid: tid,
status: 'ok'
});
}
}
});
}
Topics.unpin = function(tid, uid, socket) {
user.getUserField(uid, 'reputation', function(rep) {
if (rep >= configs.privilege_thresholds.manage_thread) {
// Mark thread as deleted
RDB.del('tid:' + tid + ':pinned');
if (socket) {
io.sockets.in('topic_' + tid).emit('event:topic_unpinned', {
tid: tid,
status: 'ok'
});
}
}
});
}
}(exports));

View File

@@ -190,6 +190,14 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
socket.on('api:topic.unlock', function(data) {
modules.topics.unlock(data.tid, uid, socket);
});
socket.on('api:topic.pin', function(data) {
modules.topics.pin(data.tid, uid, socket);
});
socket.on('api:topic.unpin', function(data) {
modules.topics.unpin(data.tid, uid, socket);
});
});
}(SocketIO));