-
Notifications
You must be signed in to change notification settings - Fork 101
Ks 024 sep 23 email notification 1959 #2214
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
Merged
MuhammadKhalilzadeh
merged 7 commits into
develop
from
ks-024-Sep-23-email-notification-1959
Sep 26, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
657520a
feat(notifications): add user-added-as-admin notification flow
solan117 1856a08
refactor(icons): update EditIcon to use inline `style` instead of `sx…
solan117 1576526
Merge branch 'develop' into ks-024-Sep-23-email-notification-1959
solan117 a8d50e9
Merge branch 'develop' into ks-024-Sep-23-email-notification-1959
solan117 44e03fa
fix(notifications): correct adminId in `sendUserAddedAdminNotificatio…
solan117 cb7fda3
style(templates): align text and adjust attributes in admin notificat…
solan117 34c0fa4
style(templates): adjust body width and padding for admin notificatio…
solan117 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...s/services/projectCreationNotification.ts → ...tification/projectCreationNotification.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
Servers/services/userNotification/userAddedAdminNotification.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import { notificationService } from "../notificationService"; | ||
| import { getUserByIdQuery } from "../../utils/user.utils"; | ||
| import { frontEndUrl } from "../../config/constants"; | ||
| import { | ||
| logProcessing, | ||
| logSuccess, | ||
| logFailure, | ||
| } from "../../utils/logger/logHelper"; | ||
|
|
||
|
|
||
| export interface UserAddedAdminNotification { | ||
| projectId: number; | ||
| projectName: string; | ||
| adminId: number; | ||
| userId: number; | ||
| } | ||
|
|
||
|
|
||
| export const sendUserAddedAdminNotification = async( | ||
| data: UserAddedAdminNotification | ||
| ): Promise<void> => { | ||
| logProcessing({ | ||
| description: `Sending user added as admin notification for project: ${data.projectName}`, | ||
| functionName: "sendUserAddedAdminNotification", | ||
| fileName: "userAddedAdminNotification.ts", | ||
| }); | ||
|
|
||
| try{ | ||
|
|
||
| // Get admin user details | ||
| const adminUser = await getUserByIdQuery(data.adminId); | ||
| if (!adminUser) { | ||
| throw new Error(`Admin user not found with ID: ${data.adminId}`); | ||
| } | ||
|
|
||
| // Get user details | ||
| const user = await getUserByIdQuery(data.userId); | ||
| if (!user) { | ||
| throw new Error(`User not found with ID: ${data.userId}`); | ||
| } | ||
|
|
||
| if(!user.email || user.email.trim() === ''){ | ||
| throw new Error(`User email is missing or invalid for user ID: ${data.userId}`); | ||
| } | ||
|
|
||
| // Construct project URL | ||
| const projectUrl = `${frontEndUrl}/project-view?projectId=${data.projectId}`; | ||
|
|
||
| // Prepare template data | ||
| const templateData = { | ||
| project_name: data.projectName, | ||
| actor_name: adminUser.name, | ||
| project_url: projectUrl, | ||
| user_name: user.name | ||
| }; | ||
|
|
||
| // Send the email using core notification service | ||
| const subject = `You are now a project admin for ${data.projectName}`; | ||
| await notificationService.sendEmailWithTemplate( | ||
| user.email, | ||
| subject, | ||
| "user-added-admin.mjml", | ||
| templateData | ||
| ); | ||
|
|
||
| await logSuccess({ | ||
| eventType: "Update", | ||
| description: `Added as Admin notification sent to ${user.email}`, | ||
| functionName: "sendUserAddedAdminNotification", | ||
| fileName: "userAddedAdminNotification.ts", | ||
| }); | ||
| } catch (error) { | ||
| await logFailure({ | ||
| eventType: "Update", | ||
| description: `Failed to send user added as admin notification`, | ||
| functionName: "sendUserAddedAdminNotification", | ||
| fileName: "userAddedAdminNotification.ts", | ||
| error: error as Error, | ||
| }); | ||
| throw error; | ||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <mjml> | ||
| <mj-head> | ||
| <mj-font name="Roboto" href="https://fonts.googleapis.com/css?family=Roboto:300,500"></mj-font> | ||
| <mj-attributes> | ||
| <mj-all font-family="Roboto, Helvetica, sans-serif"></mj-all> | ||
| <mj-text font-weight="300" font-size="14px" color="#616161" line-height="24px"></mj-text> | ||
| <mj-section padding="0px"></mj-section> | ||
| </mj-attributes> | ||
| </mj-head> | ||
| <mj-body width="100%"> | ||
| <mj-section text-align="left" padding="0px"> | ||
| <mj-column width="100%" vertical-align="top"> | ||
| <mj-text align="left"> | ||
| <h2 style="color: #2c3e50; margin-bottom: 20px;">You are now a project admin</h2> | ||
| <p>Hi {{user_name}},</p> | ||
| <p>You have been added as a project admin for <strong>{{project_name}}</strong> by {{actor_name}}.</p> | ||
| <p>As an admin, you can manage members, policies, and controls.</p> | ||
| <p style="margin: 20px 0;"> | ||
| <a href="{{project_url}}" style="background-color: #3498db; color: white; padding: 12px 24px; text-decoration: none; border-radius: 4px; display: inline-block;">Open project</a> | ||
| </p> | ||
| <p style="margin-top: 30px; color: #7f8c8d; font-size: 12px;"> | ||
| Sent from VerifyWise | ||
| </p> | ||
| </mj-text> | ||
| </mj-column> | ||
| </mj-section> | ||
| </mj-body> | ||
| </mjml> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.