mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-09-02 03:17:06 +02:00
Merge branch 'master' into develop
This commit is contained in:
@@ -91,7 +91,14 @@ module.exports = function (SocketPosts) {
|
||||
]);
|
||||
const cidToAllowed = _.zipObject(uniqCids, canRead);
|
||||
const checks = cids.map(
|
||||
(cid, index) => isAdmin || isMod[index] || (cidToAllowed[cid] && !!meta.config.votesArePublic)
|
||||
(cid, index) => isAdmin || isMod[index] ||
|
||||
(
|
||||
cidToAllowed[cid] &&
|
||||
(
|
||||
meta.config.voteVisibility === 'all' ||
|
||||
(meta.config.voteVisibility === 'loggedin' && parseInt(uid, 10) > 0)
|
||||
)
|
||||
)
|
||||
);
|
||||
return isArray ? checks : checks[0];
|
||||
}
|
||||
|
||||
@@ -116,10 +116,10 @@ Topics.getTopicsByTids = async function (tids, options) {
|
||||
};
|
||||
}
|
||||
|
||||
const [result, hasRead, isIgnored, bookmarks, callerSettings] = await Promise.all([
|
||||
const [result, hasRead, followData, bookmarks, callerSettings] = await Promise.all([
|
||||
loadTopics(),
|
||||
Topics.hasReadTopics(tids, uid),
|
||||
Topics.isIgnoring(tids, uid),
|
||||
Topics.getFollowData(tids, uid),
|
||||
Topics.getUserBookmarks(tids, uid),
|
||||
user.getSettings(uid),
|
||||
]);
|
||||
@@ -136,8 +136,9 @@ Topics.getTopicsByTids = async function (tids, options) {
|
||||
}
|
||||
topic.teaser = result.teasers[i] || null;
|
||||
topic.isOwner = topic.uid === parseInt(uid, 10);
|
||||
topic.ignored = isIgnored[i];
|
||||
topic.unread = parseInt(uid, 10) <= 0 || (!hasRead[i] && !isIgnored[i]);
|
||||
topic.ignored = followData[i].ignoring;
|
||||
topic.followed = followData[i].following;
|
||||
topic.unread = parseInt(uid, 10) <= 0 || (!hasRead[i] && !topic.ignored[i]);
|
||||
topic.bookmark = bookmarks[i] && (sortNewToOld ?
|
||||
Math.max(1, topic.postcount + 2 - bookmarks[i]) :
|
||||
Math.min(topic.postcount, bookmarks[i] + 1));
|
||||
|
||||
16
src/upgrades/3.8.2/vote-visibility-config.js
Normal file
16
src/upgrades/3.8.2/vote-visibility-config.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
|
||||
'use strict';
|
||||
|
||||
const db = require('../../database');
|
||||
|
||||
module.exports = {
|
||||
name: 'Add vote visibility config field',
|
||||
timestamp: Date.UTC(2024, 4, 24),
|
||||
method: async function () {
|
||||
const current = await db.getObjectField('config', 'votesArePublic');
|
||||
const isPublic = parseInt(current, 10) === 1;
|
||||
await db.setObjectField('config', 'voteVisibility', isPublic ? 'all' : 'privileged');
|
||||
await db.deleteObjectField('config', 'votesArePublic');
|
||||
},
|
||||
};
|
||||
@@ -14,9 +14,13 @@
|
||||
<input type="checkbox" class="form-check-input" id="downvote:disabled" data-field="downvote:disabled">
|
||||
<label for="downvote:disabled" class="form-check-label">[[admin/settings/reputation:disable-down-voting]]</label>
|
||||
</div>
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input type="checkbox" class="form-check-input" id="votesArePublic" data-field="votesArePublic">
|
||||
<label for="votesArePublic" class="form-check-label">[[admin/settings/reputation:votes-are-public]]</label>
|
||||
<div>
|
||||
<label for="voteVisibility" class="form-check-label">[[admin/settings/reputation:vote-visibility]]</label>
|
||||
<select id="voteVisibility" data-field="voteVisibility" class="form-select">
|
||||
<option value="all">[[admin/settings/reputation:vote-visibility-all]]</option>
|
||||
<option value="loggedin">[[admin/settings/reputation:vote-visibility-loggedin]]</option>
|
||||
<option value="privileged">[[admin/settings/reputation:vote-visibility-privileged]]</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user