Skip to content

Commit

Permalink
fix(members): don't notify on unexisting user
Browse files Browse the repository at this point in the history
  • Loading branch information
mtthp committed May 15, 2024
1 parent 0a11d8d commit fbc2b1d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/models/member.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,14 @@ export async function heartbeatMembers(memberIds, referenceDate) {
}

await Promise.all(memberIds.map(async memberId => {
const updatedUser = await mongo.db.collection('users').findOneAndUpdate(
const userBeforeUpdate = await mongo.db.collection('users').findOneAndUpdate(
{_id: memberId},
{$set: {'profile.heartbeat': referenceDate.toISOString()}}
)

notifyUserBalanceDepletionOnArrival(updatedUser.value, referenceDate)
if (userBeforeUpdate.value) {
notifyUserBalanceDepletionOnArrival(userBeforeUpdate.value, referenceDate)
}
}))
}

Expand Down

0 comments on commit fbc2b1d

Please sign in to comment.