From 6dc84deca93e7bc8688ca1dccd18bd8d77a7d275 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Fri, 5 Oct 2018 14:37:44 -0400 Subject: [PATCH] allow admins mods to watch/ignore categories for other users --- public/src/client/account/categories.js | 2 +- src/socket.io/categories.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/public/src/client/account/categories.js b/public/src/client/account/categories.js index 84202b6696..b5feb6faa6 100644 --- a/public/src/client/account/categories.js +++ b/public/src/client/account/categories.js @@ -18,7 +18,7 @@ define('forum/account/categories', ['forum/account/header'], function (header) { var $this = $(this); var command = $this.attr('component') === 'category/watching' ? 'watch' : 'ignore'; - socket.emit('categories.' + command, cid, function (err, modified_cids) { + socket.emit('categories.' + command, { cid: cid, uid: ajaxify.data.uid }, function (err, modified_cids) { if (err) { return app.alertError(err.message); } diff --git a/src/socket.io/categories.js b/src/socket.io/categories.js index 8c7ac5d394..97bdc7d44c 100644 --- a/src/socket.io/categories.js +++ b/src/socket.io/categories.js @@ -174,9 +174,17 @@ SocketCategories.ignore = function (socket, cid, callback) { }; function ignoreOrWatch(fn, socket, cid, callback) { + var targetUid = socket.uid; var cids = [parseInt(cid, 10)]; + if (typeof cid === 'object') { + targetUid = cid.uid; + cids = [parseInt(cid.cid, 10)]; + } async.waterfall([ + function (next) { + user.isAdminOrGlobalModOrSelf(socket.uid, targetUid, next); + }, function (next) { db.getSortedSetRange('categories:cid', 0, -1, next); }, @@ -201,11 +209,11 @@ function ignoreOrWatch(fn, socket, cid, callback) { } while (cat); async.each(cids, function (cid, next) { - fn(socket.uid, cid, next); + fn(targetUid, cid, next); }, next); }, function (next) { - topics.pushUnreadCount(socket.uid, next); + topics.pushUnreadCount(targetUid, next); }, function (next) { next(null, cids);