fix: Organization's Team invite emails (#12843)

Co-authored-by: Hariom <hariombalhara@gmail.com>
This commit is contained in:
Somay Chauhan 2023-12-20 21:21:42 +05:30 committed by GitHub
parent f07d0479d4
commit 68d40cabbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 19 deletions

View File

@ -143,6 +143,7 @@
"request_another_invitation_email": "If you prefer not to use {{toEmail}} as your {{appName}} email or already have a {{appName}} account, please request another invitation to that email.", "request_another_invitation_email": "If you prefer not to use {{toEmail}} as your {{appName}} email or already have a {{appName}} account, please request another invitation to that email.",
"you_have_been_invited": "You have been invited to join the team {{teamName}}", "you_have_been_invited": "You have been invited to join the team {{teamName}}",
"user_invited_you": "{{user}} invited you to join the {{entity}} {{team}} on {{appName}}", "user_invited_you": "{{user}} invited you to join the {{entity}} {{team}} on {{appName}}",
"user_invited_you_to_subteam": "{{user}} invited you to join the team {{team}} of organization {{parentTeamName}} on {{appName}}",
"hidden_team_member_title": "You are hidden in this team", "hidden_team_member_title": "You are hidden in this team",
"hidden_team_member_message": "Your seat is not paid for, either Upgrade to PRO or let the team owner know they can pay for your seat.", "hidden_team_member_message": "Your seat is not paid for, either Upgrade to PRO or let the team owner know they can pay for your seat.",
"hidden_team_owner_message": "You need a pro account to use teams, you are hidden until you upgrade.", "hidden_team_owner_message": "You need a pro account to use teams, you are hidden until you upgrade.",
@ -1746,9 +1747,11 @@
"organizer_timezone": "Organizer timezone", "organizer_timezone": "Organizer timezone",
"email_user_cta": "View Invitation", "email_user_cta": "View Invitation",
"email_no_user_invite_heading_team": "Youve been invited to join a {{appName}} team", "email_no_user_invite_heading_team": "Youve been invited to join a {{appName}} team",
"email_no_user_invite_heading_subteam": "Youve been invited to join a team of {{parentTeamName}} organization",
"email_no_user_invite_heading_org": "Youve been invited to join a {{appName}} organization", "email_no_user_invite_heading_org": "Youve been invited to join a {{appName}} organization",
"email_no_user_invite_subheading": "{{invitedBy}} has invited you to join their team on {{appName}}. {{appName}} is the event-juggling scheduler that enables you and your team to schedule meetings without the email tennis.", "email_no_user_invite_subheading": "{{invitedBy}} has invited you to join their team on {{appName}}. {{appName}} is the event-juggling scheduler that enables you and your team to schedule meetings without the email tennis.",
"email_user_invite_subheading_team": "{{invitedBy}} has invited you to join their team `{{teamName}}` on {{appName}}. {{appName}} is the event-juggling scheduler that enables you and your team to schedule meetings without the email tennis.", "email_user_invite_subheading_team": "{{invitedBy}} has invited you to join their team `{{teamName}}` on {{appName}}. {{appName}} is the event-juggling scheduler that enables you and your team to schedule meetings without the email tennis.",
"email_user_invite_subheading_subteam": "{{invitedBy}} has invited you to join the team `{{teamName}}` in their organization {{parentTeamName}} on {{appName}}. {{appName}} is the event-juggling scheduler that enables you and your team to schedule meetings without the email tennis.",
"email_user_invite_subheading_org": "{{invitedBy}} has invited you to join their organization `{{teamName}}` on {{appName}}. {{appName}} is the event-juggling scheduler that enables you and your organization to schedule meetings without the email tennis.", "email_user_invite_subheading_org": "{{invitedBy}} has invited you to join their organization `{{teamName}}` on {{appName}}. {{appName}} is the event-juggling scheduler that enables you and your organization to schedule meetings without the email tennis.",
"email_no_user_invite_steps_intro": "Well walk you through a few short steps and youll be enjoying stress free scheduling with your {{entity}} in no time.", "email_no_user_invite_steps_intro": "Well walk you through a few short steps and youll be enjoying stress free scheduling with your {{entity}} in no time.",
"email_no_user_step_one": "Choose your username", "email_no_user_step_one": "Choose your username",

View File

@ -12,6 +12,7 @@ type TeamInvite = {
joinLink: string; joinLink: string;
isCalcomMember: boolean; isCalcomMember: boolean;
isOrg: boolean; isOrg: boolean;
parentTeamName: string | undefined;
}; };
export const TeamInviteEmail = ( export const TeamInviteEmail = (
@ -19,17 +20,22 @@ export const TeamInviteEmail = (
) => { ) => {
return ( return (
<V2BaseEmailHtml <V2BaseEmailHtml
subject={props.language("user_invited_you", { subject={props.language(`user_invited_you${props.parentTeamName ? "_to_subteam" : ""}`, {
user: props.from, user: props.from,
team: props.teamName, team: props.teamName,
appName: APP_NAME, appName: APP_NAME,
parentTeamName: props.parentTeamName,
entity: props.language(props.isOrg ? "organization" : "team").toLowerCase(), entity: props.language(props.isOrg ? "organization" : "team").toLowerCase(),
})}> })}>
<p style={{ fontSize: "24px", marginBottom: "16px", textAlign: "center" }}> <p style={{ fontSize: "24px", marginBottom: "16px", textAlign: "center" }}>
<> <>
{props.language(`email_no_user_invite_heading_${props.isOrg ? "org" : "team"}`, { {props.language(
appName: APP_NAME, `email_no_user_invite_heading_${props.isOrg ? "org" : props.parentTeamName ? "subteam" : "team"}`,
})} {
appName: APP_NAME,
parentTeamName: props.parentTeamName,
}
)}
</> </>
</p> </p>
<img <img
@ -56,11 +62,15 @@ export const TeamInviteEmail = (
lineHeightStep: "24px", lineHeightStep: "24px",
}}> }}>
<> <>
{props.language(`email_user_invite_subheading_${props.isOrg ? "org" : "team"}`, { {props.language(
invitedBy: props.from, `email_user_invite_subheading_${props.isOrg ? "org" : props.parentTeamName ? "subteam" : "team"}`,
appName: APP_NAME, {
teamName: props.teamName, invitedBy: props.from,
})} appName: APP_NAME,
teamName: props.teamName,
parentTeamName: props.parentTeamName,
}
)}
</> </>
</p> </p>
<div style={{ display: "flex", justifyContent: "center" }}> <div style={{ display: "flex", justifyContent: "center" }}>

View File

@ -13,6 +13,7 @@ export type TeamInvite = {
joinLink: string; joinLink: string;
isCalcomMember: boolean; isCalcomMember: boolean;
isOrg: boolean; isOrg: boolean;
parentTeamName: string | undefined;
}; };
export default class TeamInviteEmail extends BaseEmail { export default class TeamInviteEmail extends BaseEmail {
@ -28,14 +29,18 @@ export default class TeamInviteEmail extends BaseEmail {
return { return {
to: this.teamInviteEvent.to, to: this.teamInviteEvent.to,
from: `${APP_NAME} <${this.getMailerOptions().from}>`, from: `${APP_NAME} <${this.getMailerOptions().from}>`,
subject: this.teamInviteEvent.language("user_invited_you", { subject: this.teamInviteEvent.language(
user: this.teamInviteEvent.from, `user_invited_you${this.teamInviteEvent.parentTeamName ? "_to_subteam" : ""}`,
team: this.teamInviteEvent.teamName, {
appName: APP_NAME, user: this.teamInviteEvent.from,
entity: this.teamInviteEvent team: this.teamInviteEvent.teamName,
.language(this.teamInviteEvent.isOrg ? "organization" : "team") appName: APP_NAME,
.toLowerCase(), parentTeamName: this.teamInviteEvent.parentTeamName,
}), entity: this.teamInviteEvent
.language(this.teamInviteEvent.isOrg ? "organization" : "team")
.toLowerCase(),
}
),
html: await renderEmail("TeamInviteEmail", this.teamInviteEvent), html: await renderEmail("TeamInviteEmail", this.teamInviteEvent),
text: "", text: "",
}; };

View File

@ -145,6 +145,7 @@ export const inviteMemberHandler = async ({ ctx, input }: InviteMemberOptions) =
language: translation, language: translation,
isOrg: input.isOrg, isOrg: input.isOrg,
teamId: team.id, teamId: team.id,
currentUserParentTeamName: team?.parent?.name,
}); });
} }
} }

View File

@ -368,10 +368,11 @@ export async function sendVerificationEmail({
language: translation, language: translation,
from: ctx.user.name || `${team.name}'s admin`, from: ctx.user.name || `${team.name}'s admin`,
to: usernameOrEmail, to: usernameOrEmail,
teamName: team?.parent?.name || team.name, teamName: team.name,
joinLink: `${WEBAPP_URL}/signup?token=${token}&callbackUrl=/getting-started`, joinLink: `${WEBAPP_URL}/signup?token=${token}&callbackUrl=/getting-started`,
isCalcomMember: false, isCalcomMember: false,
isOrg: input.isOrg, isOrg: input.isOrg,
parentTeamName: team?.parent?.name,
}); });
} else { } else {
await sendOrganizationAutoJoinEmail({ await sendOrganizationAutoJoinEmail({
@ -478,12 +479,14 @@ export const sendTeamInviteEmails = async ({
language, language,
currentUserTeamName, currentUserTeamName,
currentUserName, currentUserName,
currentUserParentTeamName,
isOrg, isOrg,
teamId, teamId,
}: { }: {
language: TFunction; language: TFunction;
existingUsersWithMembersips: UserWithMembership[]; existingUsersWithMembersips: UserWithMembership[];
currentUserTeamName?: string; currentUserTeamName?: string;
currentUserParentTeamName: string | undefined;
currentUserName?: string | null; currentUserName?: string | null;
isOrg: boolean; isOrg: boolean;
teamId: number; teamId: number;
@ -529,6 +532,7 @@ export const sendTeamInviteEmails = async ({
teamName: currentUserTeamName, teamName: currentUserTeamName,
...inviteTeamOptions, ...inviteTeamOptions,
isOrg: isOrg, isOrg: isOrg,
parentTeamName: currentUserParentTeamName,
}); });
} }
}); });

View File

@ -51,9 +51,10 @@ export const resendInvitationHandler = async ({ ctx, input }: InviteMemberOption
language: translation, language: translation,
from: ctx.user.name || `${team.name}'s admin`, from: ctx.user.name || `${team.name}'s admin`,
to: input.email, to: input.email,
teamName: team?.parent?.name || team.name, teamName: team.name,
...inviteTeamOptions, ...inviteTeamOptions,
isOrg: input.isOrg, isOrg: input.isOrg,
parentTeamName: team?.parent?.name,
}); });
return input; return input;