Skip to content

Commit

Permalink
chore: invitation space id
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Aug 19, 2024
1 parent bcd9c88 commit 573d7cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/backend/src/modules/mail/templates/invite.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
<span class="preheader">{{invite_sender_name}}
with has invited you to use
<strong>undb</strong>
to collaborate with them.</span>
to space
<strong>{{space_name}}</strong>
collaborate with them.</span>
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
Expand Down
10 changes: 8 additions & 2 deletions packages/authz/src/space-member/invitation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { singleton } from "@undb/di"
import { env } from "@undb/env"
import { createLogger } from "@undb/logger"
import { injectMailService, type IMailService } from "@undb/mail"
import { injectSpaceService, type ISpaceService } from "@undb/space"
import type { InvitationDTO } from "./dto"

export interface IInvitationMailService {
Expand All @@ -14,20 +15,25 @@ export class InvitationMailService implements IInvitationMailService {
constructor(
@injectMailService()
private readonly svc: IMailService,
@injectSpaceService()
private readonly spaceService: ISpaceService,
) {}

async invite(invitation: InvitationDTO, username: string): Promise<void> {
this.logger.info(invitation, "sending invitation mail...")

const space = (await this.spaceService.getSpace({ spaceId: invitation.spaceId })).expect("space not found")

await this.svc.send({
template: "invite",
to: invitation.email,
subject: "You have been invited to join the workspace",
subject: `You have been invited to join the space ${space.name.value}`,
data: {
invite_sender_name: username,
space_name: space.name.value,
email: invitation.email,
action_url: new URL(`/invitation/${invitation.id}/accept`, env.UNDB_BASE_URL).toString(),
help_url: "",
help_url: "https://undb.io",
},
})
}
Expand Down
1 change: 1 addition & 0 deletions packages/mail/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const sendInviteInput = z
template: z.literal("invite"),
data: z.object({
invite_sender_name: z.string(),
space_name: z.string(),
email: z.string().email(),
action_url: z.string().url(),
help_url: z.string().url(),
Expand Down

0 comments on commit 573d7cf

Please sign in to comment.