mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-30 11:18:22 +02:00
thread pinning
This commit is contained in:
@@ -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));
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user