mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
commit 56582bc9eee5d81a01f42a28808b617b9c96873a Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 05:21:11 2015 -0400 added missing template commit 6462a1626e7d8d77210b6e10eace5c9214335f33 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 05:19:07 2015 -0400 sitemap index commit 3cfd56f1fbc8e03405dc394375bf5ff6eef21322 Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 04:47:52 2015 -0400 sitemap routes, controllers, and library methods for pages, categories, and topics commit e58e07c0881bdbe16d503b4679b85f761b02163c Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 04:07:39 2015 -0400 added groups to sitemap commit7ee584b632
Author: Julian Lam <julian@designcreateplay.com> Date: Tue Oct 27 01:43:06 2015 -0400 If notification dropdown is double-clicked, all notifications are marked read commit488f147bef
Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:39:19 2015 -0400 closes #3781 commit5e1bd58a02
Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:28:30 2015 -0400 closes #3782 commit57d3980267
Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 22:16:08 2015 -0400 closes #3790 commit555c5b82da
Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 21:19:20 2015 -0400 check user settings commit5454862c1c
Author: barisusakli <barisusakli@gmail.com> Date: Mon Oct 26 20:26:02 2015 -0400 wait for all callbacks when creating tags commit051c5077eb
Merge:839fd93
e0e04ef
Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Mon Oct 26 09:54:12 2015 -0400 Merge pull request #3792 from drlogout/master Fixed wrong method name in socket.io/groups.js from isAdmin to isAdmi… commite0e04ef892
Author: Christian Nolte <hello@noltech.net> Date: Mon Oct 26 14:50:32 2015 +0100 Fixed wrong method name in socket.io/groups.js from isAdmin to isAdministrator commit839fd935ad
Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 21:54:35 2015 -0400 add back thread tools filter commit37060bf1a3
Merge:5820a19
bf918bd
Author: Barış Soner Uşaklı <barisusakli@gmail.com> Date: Sun Oct 25 18:13:06 2015 -0400 Merge pull request #3787 from cubehouse/patch-1 Upgrade script fails on some consoles commit5820a193f6
Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 17:04:46 2015 -0400 closes #3789 commit0d88d52557
Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 17:03:33 2015 -0400 up theme commit9bc43ba5e1
Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 16:57:42 2015 -0400 closes #3788 commitaafd4b6984
Author: barisusakli <barisusakli@gmail.com> Date: Sun Oct 25 15:56:17 2015 -0400 closes #3786 commitbf918bd016
Author: James Holding <cubehouse@users.noreply.github.com> Date: Sun Oct 25 10:14:00 2015 +0000 Upgrade script fails on some consoles The upgrade script errors/fails on some consoles if the stdout.columns isn't set (my console did this when upgrading a Docker instance of NodeBB). Checking for stdout.columns before using, falling back to a couple of spaces for slightly prettiness if we can't work out the console width.
110 lines
3.0 KiB
JavaScript
110 lines
3.0 KiB
JavaScript
'use strict';
|
|
|
|
var async = require('async');
|
|
var topics = require('../../topics');
|
|
var events = require('../../events');
|
|
var privileges = require('../../privileges');
|
|
var plugins = require('../../plugins');
|
|
var socketHelpers = require('../helpers');
|
|
|
|
module.exports = function(SocketTopics) {
|
|
|
|
SocketTopics.loadTopicTools = function(socket, data, callback) {
|
|
if (!socket.uid) {
|
|
return;
|
|
}
|
|
if (!data) {
|
|
return callback(new Error('[[error:invalid-data]]'));
|
|
}
|
|
var topic;
|
|
async.waterfall([
|
|
function (next) {
|
|
async.parallel({
|
|
topic: function(next) {
|
|
topics.getTopicData(data.tid, next);
|
|
},
|
|
privileges: function(next) {
|
|
privileges.topics.get(data.tid, socket.uid, next);
|
|
}
|
|
}, next);
|
|
},
|
|
function (results, next) {
|
|
topic = results.topic;
|
|
topic.privileges = results.privileges;
|
|
plugins.fireHook('filter:topic.thread_tools', {topic: results.topic, uid: socket.uid, tools: []}, next);
|
|
},
|
|
function (data, next) {
|
|
topic.deleted = parseInt(topic.deleted, 10) === 1;
|
|
topic.locked = parseInt(topic.locked, 10) === 1;
|
|
topic.pinned = parseInt(topic.pinned, 10) === 1;
|
|
topic.thread_tools = data.tools;
|
|
next(null, topic);
|
|
}
|
|
], callback);
|
|
};
|
|
|
|
SocketTopics.delete = function(socket, data, callback) {
|
|
SocketTopics.doTopicAction('delete', 'event:topic_deleted', socket, data, callback);
|
|
};
|
|
|
|
SocketTopics.restore = function(socket, data, callback) {
|
|
SocketTopics.doTopicAction('restore', 'event:topic_restored', socket, data, callback);
|
|
};
|
|
|
|
SocketTopics.purge = function(socket, data, callback) {
|
|
SocketTopics.doTopicAction('purge', 'event:topic_purged', socket, data, callback);
|
|
};
|
|
|
|
SocketTopics.lock = function(socket, data, callback) {
|
|
SocketTopics.doTopicAction('lock', 'event:topic_locked', socket, data, callback);
|
|
};
|
|
|
|
SocketTopics.unlock = function(socket, data, callback) {
|
|
SocketTopics.doTopicAction('unlock', 'event:topic_unlocked', socket, data, callback);
|
|
};
|
|
|
|
SocketTopics.pin = function(socket, data, callback) {
|
|
SocketTopics.doTopicAction('pin', 'event:topic_pinned', socket, data, callback);
|
|
};
|
|
|
|
SocketTopics.unpin = function(socket, data, callback) {
|
|
SocketTopics.doTopicAction('unpin', 'event:topic_unpinned', socket, data, callback);
|
|
};
|
|
|
|
SocketTopics.doTopicAction = function(action, event, socket, data, callback) {
|
|
callback = callback || function() {};
|
|
if (!socket.uid) {
|
|
return;
|
|
}
|
|
|
|
if (!data || !Array.isArray(data.tids) || !data.cid) {
|
|
return callback(new Error('[[error:invalid-tid]]'));
|
|
}
|
|
|
|
if (typeof topics.tools[action] !== 'function') {
|
|
return callback();
|
|
}
|
|
|
|
async.each(data.tids, function(tid, next) {
|
|
topics.tools[action](tid, socket.uid, function(err, data) {
|
|
if (err) {
|
|
return next(err);
|
|
}
|
|
|
|
socketHelpers.emitToTopicAndCategory(event, data);
|
|
|
|
if (action === 'delete' || action === 'restore' || action === 'purge') {
|
|
events.log({
|
|
type: 'topic-' + action,
|
|
uid: socket.uid,
|
|
ip: socket.ip,
|
|
tid: tid
|
|
});
|
|
}
|
|
|
|
next();
|
|
});
|
|
}, callback);
|
|
};
|
|
|
|
}; |