fix: revert introduction of toPid into post intFields, manually cast toPid as int in getPostSummaryByPids if present and numeric

This commit is contained in:
Julian Lam
2024-02-21 15:15:59 -05:00
parent eaba2aa37f
commit 3a870360c4
2 changed files with 6 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ const activitypub = require('../activitypub');
const utils = require('../utils'); const utils = require('../utils');
const intFields = [ const intFields = [
'uid', 'pid', 'tid', 'toPid', 'deleted', 'timestamp', 'uid', 'pid', 'tid', 'deleted', 'timestamp',
'upvotes', 'downvotes', 'deleterUid', 'edited', 'upvotes', 'downvotes', 'deleterUid', 'edited',
'replies', 'bookmarks', 'replies', 'bookmarks',
]; ];
@@ -62,7 +62,7 @@ function modifyPost(post, fields) {
const _intFields = [...intFields]; const _intFields = [...intFields];
if (post) { if (post) {
['pid', 'uid', 'tid', 'toPid'].forEach((prop) => { ['pid', 'uid', 'tid'].forEach((prop) => {
if ( if (
post.hasOwnProperty(prop) && post.hasOwnProperty(prop) &&
(activitypub.helpers.isUri(post[prop]) || validator.isUUID(String(post[prop]))) (activitypub.helpers.isUri(post[prop]) || validator.isUUID(String(post[prop])))

View File

@@ -44,6 +44,10 @@ module.exports = function (Posts) {
if (!uidToUser.hasOwnProperty(post.uid)) { if (!uidToUser.hasOwnProperty(post.uid)) {
post.uid = 0; post.uid = 0;
} }
// toPid is nullable so it is casted separately
post.toPid = utils.isNumber(post.toPid) ? parseInt(post.toPid, 10) : post.toPid;
post.user = uidToUser[post.uid]; post.user = uidToUser[post.uid];
Posts.overrideGuestHandle(post, post.handle); Posts.overrideGuestHandle(post, post.handle);
post.handle = undefined; post.handle = undefined;