Skip to content

Commit

Permalink
fixing invitation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ambrazasp committed Dec 7, 2023
1 parent 9cf1aa8 commit 1599d46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion services/usersLocal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export default class UsersLocalService extends moleculer.Service {
return { ...user, url };
}

await sendUserInvitationEmail(user.email, url, meta.user, app.settings?.productNameTo);
await sendUserInvitationEmail(user.email, url, meta?.user, app.settings?.productNameTo);
}

return user;
Expand Down
11 changes: 7 additions & 4 deletions utils/mails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ export function emailCanBeSent() {
export function sendUserInvitationEmail(
email: string,
invitationUrl: string,
inviter: User,
productName: string,
inviter?: User,
productName?: string,
) {
if (!userInviteTemplateId) return;

const inviterName =
inviter?.firstName || inviter?.lastName ? `${inviter.firstName} ${inviter.lastName}` : '';

return client?.sendEmailWithTemplate({
From: sender,
To: email.toLowerCase(),
TemplateId: userInviteTemplateId,
TemplateModel: {
invite_sender_name: `${inviter.firstName} ${inviter.lastName}`,
invite_sender_email: inviter.email,
invite_sender_name: inviterName,
invite_sender_email: inviter?.email || '',
action_url: invitationUrl,
product_name: productName,
},
Expand Down

0 comments on commit 1599d46

Please sign in to comment.