fix: allow guests to load topic tools if they have privilege to view them

display errors from topics.loadTopicTools
This commit is contained in:
Barış Soner Uşaklı
2025-05-30 09:22:06 -04:00
parent 0c1a61839e
commit 78de8c6da1
2 changed files with 2 additions and 5 deletions

View File

@@ -225,7 +225,7 @@ define('forum/topic/threadTools', [
return;
}
dropdownMenu.html(helpers.generatePlaceholderWave([8, 8, 8]));
const data = await socket.emit('topics.loadTopicTools', { tid: ajaxify.data.tid, cid: ajaxify.data.cid });
const data = await socket.emit('topics.loadTopicTools', { tid: ajaxify.data.tid, cid: ajaxify.data.cid }).catch(alerts.error);
const html = await app.parseAndTranslate('partials/topic/topic-menu-list', data);
$(dropdownMenu).attr('data-loaded', 'true').html(html);
hooks.fire('action:topic.tools.load', {

View File

@@ -6,9 +6,6 @@ const plugins = require('../../plugins');
module.exports = function (SocketTopics) {
SocketTopics.loadTopicTools = async function (socket, data) {
if (!socket.uid) {
throw new Error('[[error:no-privileges]]');
}
if (!data) {
throw new Error('[[error:invalid-data]]');
}
@@ -21,7 +18,7 @@ module.exports = function (SocketTopics) {
if (!topicData) {
throw new Error('[[error:no-topic]]');
}
if (!userPrivileges['topics:read']) {
if (!userPrivileges['topics:read'] || !userPrivileges.view_thread_tools) {
throw new Error('[[error:no-privileges]]');
}
topicData.privileges = userPrivileges;