fix: remove intFields hack and update db.parseIntFields to only parseInt if field value is a number

This commit is contained in:
Julian Lam
2024-03-06 11:45:29 -05:00
parent cda25bb646
commit f368a1a87f
5 changed files with 10 additions and 26 deletions

View File

@@ -59,19 +59,8 @@ module.exports = function (Posts) {
};
function modifyPost(post, fields) {
const _intFields = [...intFields];
if (post) {
['pid', 'uid', 'tid'].forEach((prop) => {
if (
post.hasOwnProperty(prop) &&
(activitypub.helpers.isUri(post[prop]) || validator.isUUID(String(post[prop])))
) {
_intFields.splice(_intFields.indexOf(prop), 1);
}
});
db.parseIntFields(post, _intFields, fields);
db.parseIntFields(post, intFields, fields);
if (post.hasOwnProperty('upvotes') && post.hasOwnProperty('downvotes')) {
post.votes = post.upvotes - post.downvotes;
}