Skip to content

Commit

Permalink
refactor: move parseInt to filter
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Apr 11, 2024
1 parent 48281f9 commit 52e7152
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/flags.js
Expand Up @@ -795,12 +795,10 @@ Flags.resolveUserPostFlags = async function (uid, callerUid) {
if (meta.config['flags:autoResolveOnBan']) {
await batch.processSortedSet(`uid:${uid}:posts`, async (pids) => {
let postData = await posts.getPostsFields(pids, ['pid', 'flagId']);
postData = postData.filter(p => p && p.flagId);
postData = postData.filter(p => p && p.flagId && parseInt(p.flagId, 10));
for (const postObj of postData) {
if (parseInt(postObj.flagId, 10)) {
// eslint-disable-next-line no-await-in-loop
await Flags.update(postObj.flagId, callerUid, { state: 'resolved' });
}
// eslint-disable-next-line no-await-in-loop
await Flags.update(postObj.flagId, callerUid, { state: 'resolved' });
}
}, {
batch: 500,
Expand Down

0 comments on commit 52e7152

Please sign in to comment.