diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index 27a7d788..9519c443 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine as build +FROM node:20-alpine AS build WORKDIR /app diff --git a/apps/api/src/common/api-key-roles.ts b/apps/api/src/common/api-key-roles.ts index 4c395c86..e7f8d091 100644 --- a/apps/api/src/common/api-key-roles.ts +++ b/apps/api/src/common/api-key-roles.ts @@ -1,5 +1,4 @@ -import { ApiKeyWorkspaceRole } from '@prisma/client' -import { WorkspaceRole } from '@prisma/client' +import { ApiKeyWorkspaceRole, WorkspaceRole } from '@prisma/client' export const ApiKeyWorkspaceRoles: { [key in WorkspaceRole]: ApiKeyWorkspaceRole[] diff --git a/apps/api/src/mail/services/interface.service.ts b/apps/api/src/mail/services/interface.service.ts index 3d4c1b90..c952e838 100644 --- a/apps/api/src/mail/services/interface.service.ts +++ b/apps/api/src/mail/services/interface.service.ts @@ -5,21 +5,15 @@ export const MAIL_SERVICE = 'MAIL_SERVICE' export interface IMailService { sendOtp(email: string, otp: string): Promise - workspaceInvitationMailForRegisteredUser( + workspaceInvitationMailForUsers( email: string, workspace: string, actionUrl: string, invitedBy: string, - role: WorkspaceRole + role: WorkspaceRole, + forRegisteredUser: boolean ): Promise - workspaceInvitationMailForNonRegisteredUser( - email: string, - workspace: string, - actionUrl: string, - invitedBy: string, - role: WorkspaceRole - ): Promise accountLoginEmail(email: string): Promise diff --git a/apps/api/src/mail/services/mail.service.ts b/apps/api/src/mail/services/mail.service.ts index 521b28ac..5cda462f 100644 --- a/apps/api/src/mail/services/mail.service.ts +++ b/apps/api/src/mail/services/mail.service.ts @@ -19,22 +19,25 @@ export class MailService implements IMailService { } }) } - async workspaceInvitationMailForRegisteredUser( + async workspaceInvitationMailForUsers( email: string, workspace: string, actionUrl: string, invitee: string, - role: WorkspaceRole + role: WorkspaceRole, + forRegisteredUser: boolean ): Promise { const subject = `You have been invited to a ${workspace}` - const body = ` + const intro = forRegisteredUser? `Hello again! You've been invited to join a new workspace.`:`Hello there! We're excited to welcome you to Keyshade.` + const body = + ` Workspace Invitation

Welcome to keyshade!

-

Hello there!

+

${intro}

You have been invited to join the workspace ${workspace} by ${invitee} as ${role.toString()}.

Please click on the link below to accept the invitation.

Accept Invitation

@@ -42,38 +45,10 @@ export class MailService implements IMailService {

Best Regards,

keyshade Team

- - ` + ` await this.sendEmail(email, subject, body) } - async workspaceInvitationMailForNonRegisteredUser( - email: string, - workspace: string, - actionUrl: string, - invitee: string, - role: WorkspaceRole - ): Promise { - const subject = `You have been invited to a ${workspace}` - const body = ` - - - Workspace Invitation - - -

Welcome to keyshade!

-

Hello there!

-

You have been invited to join the workspace ${workspace} by ${invitee} as ${role.toString()}.

-

Please click on the link below to accept the invitation.

-

Accept Invitation

-

Thank you for choosing us.

-

Best Regards,

-

keyshade Team

- - - ` - await this.sendEmail(email, subject, body) - } async sendOtp(email: string, otp: string): Promise { const subject = 'Your Login OTP' diff --git a/apps/api/src/mail/services/mock.service.ts b/apps/api/src/mail/services/mock.service.ts index f9bd9e84..49878e09 100644 --- a/apps/api/src/mail/services/mock.service.ts +++ b/apps/api/src/mail/services/mock.service.ts @@ -6,29 +6,20 @@ import { WorkspaceRole } from '@prisma/client' export class MockMailService implements IMailService { private readonly log = new Logger(MockMailService.name) - async workspaceInvitationMailForRegisteredUser( + async workspaceInvitationMailForUsers( email: string, workspace: string, actionUrl: string, invitee: string, - role: WorkspaceRole + role: WorkspaceRole, + forRegisteredUser: boolean ): Promise { this.log.log( - `Workspace Invitation Mail for Registered User: ${email}, ${workspace}, ${actionUrl}, ${invitee}, ${role}` + forRegisteredUser? + `Workspace Invitation Mail for Registered User: ${email}, ${workspace}, ${actionUrl}, ${invitee}, ${role}`:`Workspace Invitation Mail for Non Registered User: ${email}, ${workspace}, ${actionUrl}, ${invitee}, ${role}` ) } - async workspaceInvitationMailForNonRegisteredUser( - email: string, - workspace: string, - actionUrl: string, - invitee: string, - role: WorkspaceRole - ): Promise { - this.log.log( - `Workspace Invitation Mail for Non Registered User: ${email}, ${workspace}, ${actionUrl}, ${invitee}, ${role}` - ) - } async adminUserCreateEmail(email: string): Promise { this.log.log(`Create pAdmin User Email: ${email}`) diff --git a/apps/api/src/workspace/service/workspace.service.ts b/apps/api/src/workspace/service/workspace.service.ts index f2ad4c44..958a053d 100644 --- a/apps/api/src/workspace/service/workspace.service.ts +++ b/apps/api/src/workspace/service/workspace.service.ts @@ -590,12 +590,13 @@ export class WorkspaceService { continue if (memberUser) { - this.mailService.workspaceInvitationMailForRegisteredUser( + this.mailService.workspaceInvitationMailForUsers( member.email, workspace.name, `${process.env.WORKSPACE_FRONTEND_URL}/workspace/${workspace.id}/join`, currentUser.name, - member.role + member.role, + true ) this.log.debug( @@ -610,7 +611,7 @@ export class WorkspaceService { this.log.debug(`Created non-registered user ${memberUser}`) - this.mailService.workspaceInvitationMailForNonRegisteredUser( + this.mailService.workspaceInvitationMailForUsers( member.email, workspace.name, `${process.env.WORKSPACE_FRONTEND_URL}/workspace/${ @@ -619,7 +620,8 @@ export class WorkspaceService { id: memberUser.id })}`, currentUser.name, - member.role + member.role, + false ) this.log.debug( diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index be12b92e..0ad25673 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine as build +FROM node:20-alpine AS build WORKDIR /app