Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(emailNotification): Add Multiple Users | Invite email didnt receive by User(s) #922

Conversation

tfjanjua
Copy link
Contributor

@tfjanjua tfjanjua commented Aug 12, 2024

Description

User(s) didnt receive invite emails when invited via Add Multiple Users. Users has been created but invite email does not sent out to users.

Why

Recently bulk uploaded users were not getting email notifications

Issue

Ref: #920

Checklist

Please delete options that are not relevant.

  • I have followed the contributing guidelines
  • I have performed a self-review of my own code
  • I have successfully tested my changes locally
  • I have added tests that prove my changes work
  • I have checked that new and existing tests pass locally with my changes
  • I have commented my code, particularly in hard-to-understand areas

@tfjanjua tfjanjua self-assigned this Aug 12, 2024
@tfjanjua tfjanjua added the bug Something isn't working label Aug 12, 2024
@Phil91 Phil91 added this to the Release 24.12 milestone Aug 14, 2024
Copy link
Member

@Phil91 Phil91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion would be to move the mail process creation into the call of _userProvisioningServiceCreateOwnCompanyIdpUsersAsync and adjust the usages accordingly.

@tfjanjua
Copy link
Contributor Author

tfjanjua commented Aug 16, 2024

My suggestion would be to move the mail process creation into the call of _userProvisioningServiceCreateOwnCompanyIdpUsersAsync and adjust the usages accordingly.

@Phil91 thanks for your suggestion, I see _userProvisioningService.CreateOwnCompanyIdpUsersAsync method and I found that we are calling this method from 8 different places (except test cases, otherwise its 24 places) and a few place has different email template and params implementation, wherever this method is been called.

e.g. in UserBusinessLogic.cs and UserUploadBusinessLogic.cs files, there are mostly 3 email templates have been used after calling the _userProvisioningService.CreateOwnCompanyIdpUsersAsync method from different places:

  1. NewUserTemplate
  2. NewUserPasswordTemplate
  3. NewUserExternalIdpTemplate

and in InvitationProcessService.cs file, there are 2 different email templates have been used after calling the _userProvisioningService.CreateOwnCompanyIdpUsersAsync method:

  1. RegistrationTemplate
  2. PasswordForRegistrationTemplate

and in RegistrationBusinessLogic.cs file, there are 2 different email templates have been used after calling the _userProvisioningService.CreateOwnCompanyIdpUsersAsync method:

  1. invite or inviteWithMessage
  2. password

So I feel like, if I move the mail process creation for UserBusinessLogic.cs and UserUploadBusinessLogic.cs files into the call of _userProvisioningService.CreateOwnCompanyIdpUsersAsync so, this would be adjustable because here we have IsSharedIdp bit to check and make decision upon email templates but I am wondering how the identification of email templates (params are more or less same) would work for InvitationProcessService.cs and RegistrationBusinessLogic.cs files? would it possible to add another param in _userProvisioningService.CreateOwnCompanyIdpUsersAsync method to check from where this method is being called and make decision of email templates? or am I missing any already placed variable with different values?

@tfjanjua tfjanjua requested a review from Phil91 August 16, 2024 09:45
@Phil91
Copy link
Member

Phil91 commented Aug 21, 2024

My suggestion would be to move the mail process creation into the call of _userProvisioningServiceCreateOwnCompanyIdpUsersAsync and adjust the usages accordingly.

@Phil91 thanks for your suggestion, I see _userProvisioningService.CreateOwnCompanyIdpUsersAsync method and I found that we are calling this method from 8 different places (except test cases, otherwise its 24 places) and a few place has different email template and params implementation, wherever this method is been called.

e.g. in UserBusinessLogic.cs and UserUploadBusinessLogic.cs files, there are mostly 3 email templates have been used after calling the _userProvisioningService.CreateOwnCompanyIdpUsersAsync method from different places:

  1. NewUserTemplate
  2. NewUserPasswordTemplate
  3. NewUserExternalIdpTemplate

and in InvitationProcessService.cs file, there are 2 different email templates have been used after calling the _userProvisioningService.CreateOwnCompanyIdpUsersAsync method:

  1. RegistrationTemplate
  2. PasswordForRegistrationTemplate

and in RegistrationBusinessLogic.cs file, there are 2 different email templates have been used after calling the _userProvisioningService.CreateOwnCompanyIdpUsersAsync method:

  1. invite or inviteWithMessage
  2. password

So I feel like, if I move the mail process creation for UserBusinessLogic.cs and UserUploadBusinessLogic.cs files into the call of _userProvisioningService.CreateOwnCompanyIdpUsersAsync so, this would be adjustable because here we have IsSharedIdp bit to check and make decision upon email templates but I am wondering how the identification of email templates (params are more or less same) would work for InvitationProcessService.cs and RegistrationBusinessLogic.cs files? would it possible to add another param in _userProvisioningService.CreateOwnCompanyIdpUsersAsync method to check from where this method is being called and make decision of email templates? or am I missing any already placed variable with different values?

@tfjanjua sorry for the late response, didn't saw the additional usages. I like the idea, instead of the parameter to define where the call came from I'd suggest to just add a parameter to pass an enumerable of the mail templates?

Phil91
Phil91 previously approved these changes Sep 11, 2024
userCreationInfos
.Select(info =>
{
userCreationInfo = info;
Copy link
Contributor

@ntruchsess ntruchsess Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this might be causing threading issues. I need to check what the specification says about synchronization and visibility of changes done from an inner Task writing to some outer scoped address that is not defined as AtomicXXX (could be a no-issue, but I'm not 100% sure, I did not yet find information about whether anything else than Task.Result that is not explicitly synchronized and being written to within the Tasks execution is guaranteed to be visible outside)
Also this relies on CreateOwnCompanyIdpUserAsync iterating userCreationInfos sequentially. If someone decides to add parallelism it would break this code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I just notice this new method is a copy of the existing method CreateOwnCompanyIdpUsersWithEmailAsync with email-generation adjusted to the SharedIdp-usecase. I'll do some reusable refactoring to accomplish this in a less fragile way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did refactor this adding a new onSuccess parameter that allows to pass a lambda that is going to be executed after each user-creation. Any db-changes applied within that lambda are being saved within the same transaction as the creation of the respective user now.
(I had to do a force-push after rebasing on latest main to resolve the conflicts)

@ntruchsess ntruchsess self-assigned this Sep 13, 2024
@ntruchsess ntruchsess force-pushed the fix/920-invite-email-not-receiving-to-invited-users branch from 5a2edaf to ca3443f Compare September 16, 2024 08:36
…ve by User(s)

User(s) didnt receive invite emails when invited via Add Multiple Users.
Users has been created but invite email does not sent out to users.

Ref: eclipse-tractusx#920
@ntruchsess ntruchsess force-pushed the fix/920-invite-email-not-receiving-to-invited-users branch 4 times, most recently from 364790d to e143220 Compare September 16, 2024 08:48
ntruchsess
ntruchsess previously approved these changes Sep 16, 2024
@ntruchsess ntruchsess force-pushed the fix/920-invite-email-not-receiving-to-invited-users branch from e143220 to 52c47f1 Compare September 16, 2024 08:57
ntruchsess
ntruchsess previously approved these changes Sep 16, 2024
@ntruchsess ntruchsess force-pushed the fix/920-invite-email-not-receiving-to-invited-users branch 2 times, most recently from 0087e90 to 55308a1 Compare September 16, 2024 10:34
Phil91
Phil91 previously approved these changes Sep 16, 2024
@ntruchsess ntruchsess force-pushed the fix/920-invite-email-not-receiving-to-invited-users branch 2 times, most recently from b08ae20 to 7563111 Compare September 16, 2024 10:46
@ntruchsess ntruchsess force-pushed the fix/920-invite-email-not-receiving-to-invited-users branch from 7563111 to ad7a05a Compare September 16, 2024 10:47
Copy link

sonarcloud bot commented Sep 16, 2024

@ntruchsess ntruchsess merged commit bb16156 into eclipse-tractusx:main Sep 16, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: USER READY
Development

Successfully merging this pull request may close these issues.

3 participants