Skip to content

The Open Source DocuSign Alternative.

fix: wrong signing invitation message (#1497)

Catalin Pit62806298cf73
diff --git a/apps/web/src/app/(signing)/sign/[token]/signing-page-view.tsx b/apps/web/src/app/(signing)/sign/[token]/signing-page-view.tsx
index 19057abf8..5e4d47ec4 100644
--- a/apps/web/src/app/(signing)/sign/[token]/signing-page-view.tsx
+++ b/apps/web/src/app/(signing)/sign/[token]/signing-page-view.tsx
@@ -53,6 +53,17 @@ export const SigningPageView = ({
}: SigningPageViewProps) => {
const { documentData, documentMeta } = document;
+ const shouldUseTeamDetails =
+ document.teamId && document.team?.teamGlobalSettings?.includeSenderDetails === false;
+
+ let senderName = document.User.name ?? '';
+ let senderEmail = `(${document.User.email})`;
+
+ if (shouldUseTeamDetails) {
+ senderName = document.team?.name ?? '';
+ senderEmail = document.team?.teamEmail?.email ? `(${document.team.teamEmail.email})` : '';
+ }
+
return (
<div className="mx-auto w-full max-w-screen-xl">
<h1
@@ -63,27 +74,41 @@ export const SigningPageView = ({
</h1>
<div className="mt-2.5 flex flex-wrap items-center justify-between gap-x-6">
- <div>
- <p
- className="text-muted-foreground truncate"
- title={document.User.name ? document.User.name : ''}
- >
- {document.User.name}
- </p>
-
- <p className="text-muted-foreground">
+ <div className="max-w-[50ch]">
+ <span className="text-muted-foreground truncate" title={senderName}>
+ {senderName} {senderEmail}
+ </span>{' '}
+ <span className="text-muted-foreground">
{match(recipient.role)
- .with(RecipientRole.VIEWER, () => (
- <Trans>({document.User.email}) has invited you to view this document</Trans>
- ))
- .with(RecipientRole.SIGNER, () => (
- <Trans>({document.User.email}) has invited you to sign this document</Trans>
- ))
- .with(RecipientRole.APPROVER, () => (
- <Trans>({document.User.email}) has invited you to approve this document</Trans>
- ))
+ .with(RecipientRole.VIEWER, () =>
+ document.teamId && !shouldUseTeamDetails ? (
+ <Trans>
+ on behalf of "{document.team?.name}" has invited you to view this document
+ </Trans>
+ ) : (
+ <Trans>has invited you to view this document</Trans>
+ ),
+ )
+ .with(RecipientRole.SIGNER, () =>
+ document.teamId && !shouldUseTeamDetails ? (
+ <Trans>
+ on behalf of "{document.team?.name}" has invited you to sign this document
+ </Trans>
+ ) : (
+ <Trans>has invited you to sign this document</Trans>
+ ),
+ )
+ .with(RecipientRole.APPROVER, () =>
+ document.teamId && !shouldUseTeamDetails ? (
+ <Trans>
+ on behalf of "{document.team?.name}" has invited you to approve this document
+ </Trans>
+ ) : (
+ <Trans>has invited you to approve this document</Trans>
+ ),
+ )
.otherwise(() => null)}
- </p>
+ </span>
</div>
<RejectDocumentDialog document={document} token={recipient.token} />
diff --git a/packages/email/template-components/template-document-invite.tsx b/packages/email/template-components/template-document-invite.tsx
index f49e0d106..8c550fbfa 100644
--- a/packages/email/template-components/template-document-invite.tsx
+++ b/packages/email/template-components/template-document-invite.tsx
@@ -61,7 +61,7 @@ export const TemplateDocumentInvite = ({
<>
{includeSenderDetails ? (
<Trans>
- {inviterName} on behalf of {teamName} has invited you to{' '}
+ {inviterName} on behalf of "{teamName}" has invited you to{' '}
{_(actionVerb).toLowerCase()}
</Trans>
) : (
diff --git a/packages/email/templates/document-invite.tsx b/packages/email/templates/document-invite.tsx
index 2db1cccdb..9f6c833c4 100644
--- a/packages/email/templates/document-invite.tsx
+++ b/packages/email/templates/document-invite.tsx
@@ -42,7 +42,7 @@ export const DocumentInviteEmailTemplate = ({
if (isTeamInvite) {
previewText = includeSenderDetails
- ? msg`${inviterName} on behalf of ${teamName} has invited you to ${action} ${documentName}`
+ ? msg`${inviterName} on behalf of "${teamName}" has invited you to ${action} ${documentName}`
: msg`${teamName} has invited you to ${action} ${documentName}`;
}
@@ -90,14 +90,16 @@ export const DocumentInviteEmailTemplate = ({
<Container className="mx-auto mt-12 max-w-xl">
<Section>
- <Text className="my-4 text-base font-semibold">
- <Trans>
- {inviterName}{' '}
- <Link className="font-normal text-slate-400" href="mailto:{inviterEmail}">
- ({inviterEmail})
- </Link>
- </Trans>
- </Text>
+ {!isTeamInvite && (
+ <Text className="my-4 text-base font-semibold">
+ <Trans>
+ {inviterName}{' '}
+ <Link className="font-normal text-slate-400" href="mailto:{inviterEmail}">
+ ({inviterEmail})
+ </Link>
+ </Trans>
+ </Text>
+ )}
<Text className="mt-2 text-base text-slate-400">
{customBody ? (
diff --git a/packages/lib/jobs/definitions/emails/send-signing-email.ts b/packages/lib/jobs/definitions/emails/send-signing-email.ts
index 32859ce14..9c1d9ba5f 100644
--- a/packages/lib/jobs/definitions/emails/send-signing-email.ts
+++ b/packages/lib/jobs/definitions/emails/send-signing-email.ts
@@ -133,7 +133,7 @@ export const SEND_SIGNING_EMAIL_JOB_DEFINITION = {
if (!emailMessage) {
emailMessage = i18n._(
team.teamGlobalSettings?.includeSenderDetails
- ? msg`${user.name} on behalf of ${team.name} has invited you to ${recipientActionVerb} the document "${document.title}".`
+ ? msg`${user.name} on behalf of "${team.name}" has invited you to ${recipientActionVerb} the document "${document.title}".`
: msg`${team.name} has invited you to ${recipientActionVerb} the document "${document.title}".`,
);
}
diff --git a/packages/lib/server-only/document/get-document-by-token.ts b/packages/lib/server-only/document/get-document-by-token.ts
index 4a6139514..3fc79709b 100644
--- a/packages/lib/server-only/document/get-document-by-token.ts
+++ b/packages/lib/server-only/document/get-document-by-token.ts
@@ -81,6 +81,17 @@ export const getDocumentAndSenderByToken = async ({
token,
},
},
+ team: {
+ select: {
+ name: true,
+ teamEmail: true,
+ teamGlobalSettings: {
+ select: {
+ includeSenderDetails: true,
+ },
+ },
+ },
+ },
},
});
diff --git a/packages/lib/server-only/document/resend-document.tsx b/packages/lib/server-only/document/resend-document.tsx
index d87be344d..fa7952213 100644
--- a/packages/lib/server-only/document/resend-document.tsx
+++ b/packages/lib/server-only/document/resend-document.tsx
@@ -134,7 +134,7 @@ export const resendDocument = async ({
emailMessage =
customEmail?.message ||
i18n._(
- msg`${user.name} on behalf of ${document.team.name} has invited you to ${recipientActionVerb} the document "${document.title}".`,
+ msg`${user.name} on behalf of "${document.team.name}" has invited you to ${recipientActionVerb} the document "${document.title}".`,
);
}