Skip to content

Commit

Permalink
Merge pull request #1157 from OneCommunityGlobal/nikhil-fix-new-user-…
Browse files Browse the repository at this point in the history
…popup-issue

Nikhil - fixed new user popup issue
  • Loading branch information
one-community authored Dec 1, 2024
2 parents a09f0d8 + 130d02c commit 1c0c000
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/controllers/profileInitialSetupController.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,22 @@ const profileInitialSetupController = function (
const link = `${baseUrl}/ProfileInitialSetup/${savedToken.token}`;
await session.commitTransaction();

const acknowledgment = await sendEmailWithAcknowledgment(
email,
'NEEDED: Complete your One Community profile setup',
sendLinkMessage(link),
);

return res.status(200).send(acknowledgment);
// Send response immediately without waiting for email acknowledgment
res.status(200).send({ message: 'Token created successfully, email is being sent.' });

// Asynchronously send the email acknowledgment
setImmediate(async () => {
try {
await sendEmailWithAcknowledgment(
email,
'NEEDED: Complete your One Community profile setup',
sendLinkMessage(link),
);
} catch (emailError) {
// Log email sending failure
LOGGER.logException(emailError, 'sendEmailWithAcknowledgment', JSON.stringify({ email, link }), null);
}
});
} catch (error) {
await session.abortTransaction();
LOGGER.logException(error, 'getSetupToken', JSON.stringify(req.body), null);
Expand Down

0 comments on commit 1c0c000

Please sign in to comment.