Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:keyshade-xyz/keyshade into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdip-b committed Feb 3, 2024
2 parents 63daab3 + 3df13f8 commit b2967c6
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 64 deletions.
2 changes: 1 addition & 1 deletion apps/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-alpine as build
FROM node:20-alpine AS build

WORKDIR /app

Expand Down
3 changes: 1 addition & 2 deletions apps/api/src/common/api-key-roles.ts
Original file line number Diff line number Diff line change
@@ -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[]
Expand Down
12 changes: 3 additions & 9 deletions apps/api/src/mail/services/interface.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@ export const MAIL_SERVICE = 'MAIL_SERVICE'
export interface IMailService {
sendOtp(email: string, otp: string): Promise<void>

workspaceInvitationMailForRegisteredUser(
workspaceInvitationMailForUsers(
email: string,
workspace: string,
actionUrl: string,
invitedBy: string,
role: WorkspaceRole
role: WorkspaceRole,
forRegisteredUser: boolean
): Promise<void>

workspaceInvitationMailForNonRegisteredUser(
email: string,
workspace: string,
actionUrl: string,
invitedBy: string,
role: WorkspaceRole
): Promise<void>

accountLoginEmail(email: string): Promise<void>

Expand Down
41 changes: 8 additions & 33 deletions apps/api/src/mail/services/mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,61 +19,36 @@ export class MailService implements IMailService {
}
})
}
async workspaceInvitationMailForRegisteredUser(
async workspaceInvitationMailForUsers(
email: string,
workspace: string,
actionUrl: string,
invitee: string,
role: WorkspaceRole
role: WorkspaceRole,
forRegisteredUser: boolean
): Promise<void> {
const subject = `You have been invited to a ${workspace}`
const body = `<!DOCTYPE html>
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 =
`<!DOCTYPE html>
<html>
<head>
<title>Workspace Invitation</title>
</head>
<body>
<h1>Welcome to keyshade!</h1>
<p>Hello there!</p>
<p>${intro}</p>
<p>You have been invited to join the workspace <strong>${workspace}</strong> by <strong>${invitee}</strong> as ${role.toString()}.</p>
<p>Please click on the link below to accept the invitation.</p>
<p><a href="${actionUrl}">Accept Invitation</a></p>
<p>Thank you for choosing us.</p>
<p>Best Regards,</p>
<p>keyshade Team</p>
</body>
</html>
`
</html>`
await this.sendEmail(email, subject, body)
}

async workspaceInvitationMailForNonRegisteredUser(
email: string,
workspace: string,
actionUrl: string,
invitee: string,
role: WorkspaceRole
): Promise<void> {
const subject = `You have been invited to a ${workspace}`
const body = `<!DOCTYPE html>
<html>
<head>
<title>Workspace Invitation</title>
</head>
<body>
<h1>Welcome to keyshade!</h1>
<p>Hello there!</p>
<p>You have been invited to join the workspace <strong>${workspace}</strong> by <strong>${invitee}</strong> as ${role.toString()}.</p>
<p>Please click on the link below to accept the invitation.</p>
<p><a href="${actionUrl}">Accept Invitation</a></p>
<p>Thank you for choosing us.</p>
<p>Best Regards,</p>
<p>keyshade Team</p>
</body>
</html>
`
await this.sendEmail(email, subject, body)
}

async sendOtp(email: string, otp: string): Promise<void> {
const subject = 'Your Login OTP'
Expand Down
19 changes: 5 additions & 14 deletions apps/api/src/mail/services/mock.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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<void> {
this.log.log(
`Workspace Invitation Mail for Non Registered User: ${email}, ${workspace}, ${actionUrl}, ${invitee}, ${role}`
)
}

async adminUserCreateEmail(email: string): Promise<void> {
this.log.log(`Create pAdmin User Email: ${email}`)
Expand Down
10 changes: 6 additions & 4 deletions apps/api/src/workspace/service/workspace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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/${
Expand All @@ -619,7 +620,8 @@ export class WorkspaceService {
id: memberUser.id
})}`,
currentUser.name,
member.role
member.role,
false
)

this.log.debug(
Expand Down
2 changes: 1 addition & 1 deletion apps/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-alpine as build
FROM node:20-alpine AS build

WORKDIR /app

Expand Down

0 comments on commit b2967c6

Please sign in to comment.