mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: parseIntFields for tids
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const validator = require('validator');
|
||||||
|
|
||||||
const db = require('../database');
|
const db = require('../database');
|
||||||
const plugins = require('../plugins');
|
const plugins = require('../plugins');
|
||||||
const activitypub = require('../activitypub');
|
const activitypub = require('../activitypub');
|
||||||
@@ -60,14 +62,15 @@ function modifyPost(post, fields) {
|
|||||||
const _intFields = [...intFields];
|
const _intFields = [...intFields];
|
||||||
|
|
||||||
if (post) {
|
if (post) {
|
||||||
if (activitypub.helpers.isUri(post.pid)) {
|
['pid', 'uid', 'tid', 'toPid'].forEach((prop) => {
|
||||||
_intFields.splice(_intFields.indexOf('pid'), 1);
|
if (
|
||||||
_intFields.splice(_intFields.indexOf('uid'), 1);
|
post.hasOwnProperty(prop) && post[prop] &&
|
||||||
_intFields.splice(_intFields.indexOf('tid'), 1);
|
(activitypub.helpers.isUri(post[prop]) || validator.isUUID(post[prop]))
|
||||||
}
|
) {
|
||||||
if (activitypub.helpers.isUri(post.toPid)) {
|
_intFields.splice(_intFields.indexOf(prop), 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;
|
||||||
|
|||||||
Reference in New Issue
Block a user