mirror of
https://github.com/documenso/documenso.git
synced 2025-11-20 03:32:14 +10:00
fix: email place holder
This commit is contained in:
@ -9,31 +9,6 @@ export type AiRecipient = {
|
||||
signingOrder?: number;
|
||||
};
|
||||
|
||||
const sanitizeEmailLocalPart = (value: string) => {
|
||||
return value
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, '.')
|
||||
.replace(/\.+/g, '.')
|
||||
.replace(/^\.+|\.+$/g, '')
|
||||
.slice(0, 32);
|
||||
};
|
||||
|
||||
export const createPlaceholderRecipientEmail = (
|
||||
name: string,
|
||||
envelopeId: string,
|
||||
position: number,
|
||||
) => {
|
||||
const normalizedName = sanitizeEmailLocalPart(name);
|
||||
const baseLocalPart = normalizedName ? `${normalizedName}.${position}` : `recipient-${position}`;
|
||||
const envelopeSuffix = envelopeId
|
||||
.replace(/[^a-z0-9]/gi, '')
|
||||
.toLowerCase()
|
||||
.slice(0, 6);
|
||||
const suffix = envelopeSuffix ? `-${envelopeSuffix}` : '';
|
||||
|
||||
return `${baseLocalPart}${suffix}@documenso.ai`;
|
||||
};
|
||||
|
||||
export const analyzeRecipientsFromDocument = async (envelopeId: string): Promise<AiRecipient[]> => {
|
||||
try {
|
||||
const response = await fetch('/api/ai/analyze-recipients', {
|
||||
@ -65,7 +40,6 @@ export const ensureRecipientEmails = (
|
||||
recipients: AiRecipient[],
|
||||
envelopeId: string,
|
||||
): RecipientForCreation[] => {
|
||||
let recipientIndex = 1;
|
||||
const allowedRoles: RecipientRole[] = [
|
||||
RecipientRole.SIGNER,
|
||||
RecipientRole.APPROVER,
|
||||
@ -73,11 +47,7 @@ export const ensureRecipientEmails = (
|
||||
];
|
||||
|
||||
return recipients.map((recipient) => {
|
||||
const email =
|
||||
recipient.email ??
|
||||
createPlaceholderRecipientEmail(recipient.name, envelopeId, recipientIndex);
|
||||
|
||||
recipientIndex += 1;
|
||||
const email = recipient.email ?? '';
|
||||
|
||||
const candidateRole = recipient.role as RecipientRole;
|
||||
const normalizedRole = allowedRoles.includes(candidateRole)
|
||||
|
||||
Reference in New Issue
Block a user