Merge pull request #13558 from overleaf/ab-group-sync-check-user-id-format

[web/cron] Check that the userId is a valid mongo ID

GitOrigin-RevId: 0c5fce5c0e474ae9d8ad8683bccade2e0b74b0c7
This commit is contained in:
Alexandre Bourdin 2023-06-26 18:27:27 +03:00 committed by Copybot
parent 2ef48be496
commit ded4de3349

View file

@ -7,6 +7,7 @@ const {
} = require('../../app/src/models/DeletedSubscription')
const minimist = require('minimist')
const _ = require('lodash')
const { ObjectId } = require('mongodb')
let FETCH_LIMIT, COMMIT, VERBOSE
@ -195,6 +196,10 @@ async function checkDeletedSubscriptionMemberships(
}
async function sendCorrectiveEvent(userId, event, subscription) {
if (!ObjectId.isValid(userId)) {
console.warn(`Skipping '${event}' for user ${userId}: invalid user ID`)
return
}
const segmentation = {
groupId: subscription._id.toString(),
subscriptionId: subscription.recurlySubscription_id,