Skip to content

Enable email notifications to users upon a role change - #3394

Merged
GspikeHalo merged 6 commits into
shenghao-add-email-notice-v2from
shenghao-add-email-notice-v3
Apr 30, 2025
Merged

GspikeHalo merged 6 commits into
shenghao-add-email-notice-v2from
shenghao-add-email-notice-v3

Conversation

@GspikeHalo

Copy link
Copy Markdown
Contributor

Purpose:

This PR enables automatic email notifications when a user's role is changed. A notification email will be sent to the user informing them of their updated role.

Changes:

  1. Add a new method createRoleChangeTemplate in EmailTemplate to generate email content for notifying users about role changes.
  2. Send an email notification to the affected user whenever their role is updated.

Demos:

[email protected] is an INACTIVE user:
image

Update the role of [email protected] to Regular:
image

Display of user email:
image

Update the role of [email protected] to ADMIN:
image

Display of user email:
image

@GspikeHalo GspikeHalo self-assigned this Apr 26, 2025
@chenlica chenlica changed the title Enable email notifications to user upon role change Enable email notifications to users upon a role change Apr 26, 2025
@chenlica

Copy link
Copy Markdown
Contributor

What's the email address used to send such notifications?

@GspikeHalo

Copy link
Copy Markdown
Contributor Author

What's the email address used to send such notifications?

It is the Gmail account that we configure under user-sys.google.smtp in application.conf during deployment.

@GspikeHalo
GspikeHalo requested a review from bobbai00 April 27, 2025 07:57

@bobbai00 bobbai00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left a minor comment

userDao.update(updatedUser)

if (roleChanged)
sendEmail(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add the email validator. You can have a util component to do it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can put the isValidEmail check inside the sendEmail function, and keep it private

@bobbai00 bobbai00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Left a minor follow-up comment.

userDao.update(updatedUser)

if (roleChanged)
sendEmail(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can put the isValidEmail check inside the sendEmail function, and keep it private

@GspikeHalo
GspikeHalo merged commit 50f519b into shenghao-add-email-notice-v2 Apr 30, 2025
@GspikeHalo
GspikeHalo deleted the shenghao-add-email-notice-v3 branch April 30, 2025 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants