Repository navigation
Conversation
…the user on payment
|
| const userByCustomerId = await this.usersService.findUserByCustomerID(customerId); | ||
| if (userByCustomerId) { | ||
| return { uuid: userByCustomerId.uuid }; | ||
| return { uuid: userByCustomerId.uuid, isRegisteredInDrive: false }; |
There was a problem hiding this comment.
Hardcoding isRegisteredInDrive: false here relies on the email lookup having failed, but that lookup swallows any error (see the catch above). If Drive fails transiently on findUserByEmail, a registered user is found by customer ID and gets the account setup email by mistake. Why not get this from a real source instead of inferring it from which lookup path succeeded?
|
|
||
| const isPendingAccountSetup = !isRegisteredInDrive && !isBusinessPlan; | ||
| if (isPendingAccountSetup) { | ||
| await this.usersService.sendAccountSetupEmail(userUuid, productName ?? FALLBACK_PLAN_NAME); |
There was a problem hiding this comment.
If this call fails, the whole webhook fails after the plan was already applied, and every retry re-applies the tier and sends the email again (the redelivery test confirms it is sent twice). Any later failure in run() (e.g. handleUserCouponRelationship) also triggers a duplicate email. Is this intentional?
There was a problem hiding this comment.
Nice catch, we have to prevent it. Should be sent just once.
| }); | ||
| }); | ||
|
|
||
| describe('Payment confirmed for a customer who has not finished the account setup', () => { |
There was a problem hiding this comment.
The initial block of code for this is... a bit weird and chaotic. Please refactor it a bit.
|
Closing due to new refactored and improved PR. |



What's new