mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: accidental overwrite of hoisted internal variable
This commit is contained in:
@@ -57,16 +57,18 @@ module.exports = function (Posts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function modifyPost(post, fields) {
|
function modifyPost(post, fields) {
|
||||||
|
const _intFields = [...intFields];
|
||||||
|
|
||||||
if (post) {
|
if (post) {
|
||||||
if (activitypub.helpers.isUri(post.pid)) {
|
if (activitypub.helpers.isUri(post.pid)) {
|
||||||
intFields.splice(intFields.indexOf('pid'), 1);
|
_intFields.splice(_intFields.indexOf('pid'), 1);
|
||||||
intFields.splice(intFields.indexOf('uid'), 1);
|
_intFields.splice(_intFields.indexOf('uid'), 1);
|
||||||
intFields.splice(intFields.indexOf('tid'), 1);
|
_intFields.splice(_intFields.indexOf('tid'), 1);
|
||||||
}
|
}
|
||||||
if (activitypub.helpers.isUri(post.toPid)) {
|
if (activitypub.helpers.isUri(post.toPid)) {
|
||||||
intFields.splice(intFields.indexOf('toPid'), 1);
|
_intFields.splice(_intFields.indexOf('toPid'), 1);
|
||||||
}
|
}
|
||||||
db.parseIntFields(post, intFields, fields);
|
db.parseIntFields(post, _intFields, fields);
|
||||||
if (post.hasOwnProperty('upvotes') && post.hasOwnProperty('downvotes')) {
|
if (post.hasOwnProperty('upvotes') && post.hasOwnProperty('downvotes')) {
|
||||||
post.votes = post.upvotes - post.downvotes;
|
post.votes = post.upvotes - post.downvotes;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,12 +95,13 @@ function modifyTopic(topic, fields) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const _intFields = [...intFields];
|
||||||
if (validator.isUUID(String(topic.tid))) {
|
if (validator.isUUID(String(topic.tid))) {
|
||||||
intFields.splice(intFields.indexOf('uid'), 1);
|
_intFields.splice(_intFields.indexOf('uid'), 1);
|
||||||
intFields.splice(intFields.indexOf('tid'), 1);
|
_intFields.splice(_intFields.indexOf('tid'), 1);
|
||||||
intFields.splice(intFields.indexOf('mainPid'), 1);
|
_intFields.splice(_intFields.indexOf('mainPid'), 1);
|
||||||
}
|
}
|
||||||
db.parseIntFields(topic, intFields, fields);
|
db.parseIntFields(topic, _intFields, fields);
|
||||||
|
|
||||||
if (topic.hasOwnProperty('title')) {
|
if (topic.hasOwnProperty('title')) {
|
||||||
topic.titleRaw = topic.title;
|
topic.titleRaw = topic.title;
|
||||||
|
|||||||
@@ -205,10 +205,12 @@ module.exports = function (User) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const _intFields = [...intFields];
|
||||||
|
|
||||||
if (activitypub.helpers.isUri(user.uid)) {
|
if (activitypub.helpers.isUri(user.uid)) {
|
||||||
intFields.splice(intFields.indexOf('uid'), 1);
|
_intFields.splice(_intFields.indexOf('uid'), 1);
|
||||||
}
|
}
|
||||||
db.parseIntFields(user, intFields, requestedFields);
|
db.parseIntFields(user, _intFields, requestedFields);
|
||||||
|
|
||||||
if (user.hasOwnProperty('username')) {
|
if (user.hasOwnProperty('username')) {
|
||||||
parseDisplayName(user, uidToSettings);
|
parseDisplayName(user, uidToSettings);
|
||||||
|
|||||||
Reference in New Issue
Block a user