mirror of
https://github.com/documenso/documenso.git
synced 2025-11-20 11:41:44 +10:00
feat: generate recipients and fields based on recipients
This commit is contained in:
@ -12,7 +12,7 @@ import { prisma } from '@documenso/prisma';
|
||||
|
||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
||||
import { mapRecipientToLegacyRecipient } from '../../utils/recipients';
|
||||
import { mapRecipientToLegacyRecipient, sanitizeRecipientName } from '../../utils/recipients';
|
||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||
|
||||
export interface CreateEnvelopeRecipientsOptions {
|
||||
@ -85,6 +85,7 @@ export const createEnvelopeRecipients = async ({
|
||||
|
||||
const normalizedRecipients = recipientsToCreate.map((recipient) => ({
|
||||
...recipient,
|
||||
name: sanitizeRecipientName(recipient.name),
|
||||
email: recipient.email.toLowerCase(),
|
||||
}));
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ import { NEXT_PUBLIC_WEBAPP_URL } from '../../constants/app';
|
||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||
import { extractDerivedDocumentEmailSettings } from '../../types/document-email';
|
||||
import { type EnvelopeIdOptions, mapSecondaryIdToDocumentId } from '../../utils/envelope';
|
||||
import { canRecipientBeModified } from '../../utils/recipients';
|
||||
import { canRecipientBeModified, sanitizeRecipientName } from '../../utils/recipients';
|
||||
import { renderEmailWithI18N } from '../../utils/render-email-with-i18n';
|
||||
import { getEmailContext } from '../email/get-email-context';
|
||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||
@ -114,6 +114,7 @@ export const setDocumentRecipients = async ({
|
||||
|
||||
const normalizedRecipients = recipients.map((recipient) => ({
|
||||
...recipient,
|
||||
name: sanitizeRecipientName(recipient.name),
|
||||
email: recipient.email.toLowerCase(),
|
||||
}));
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ import {
|
||||
import { nanoid } from '../../universal/id';
|
||||
import { createRecipientAuthOptions } from '../../utils/document-auth';
|
||||
import { type EnvelopeIdOptions, mapSecondaryIdToTemplateId } from '../../utils/envelope';
|
||||
import { sanitizeRecipientName } from '../../utils/recipients';
|
||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||
|
||||
export type SetTemplateRecipientsOptions = {
|
||||
@ -88,6 +89,7 @@ export const setTemplateRecipients = async ({
|
||||
|
||||
return {
|
||||
...recipient,
|
||||
name: sanitizeRecipientName(recipient.name),
|
||||
email: recipient.email.toLowerCase(),
|
||||
};
|
||||
});
|
||||
|
||||
@ -18,7 +18,7 @@ import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||
import { extractLegacyIds } from '../../universal/id';
|
||||
import { type EnvelopeIdOptions } from '../../utils/envelope';
|
||||
import { mapFieldToLegacyField } from '../../utils/fields';
|
||||
import { canRecipientBeModified } from '../../utils/recipients';
|
||||
import { canRecipientBeModified, sanitizeRecipientName } from '../../utils/recipients';
|
||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||
|
||||
export interface UpdateEnvelopeRecipientsOptions {
|
||||
@ -108,9 +108,18 @@ export const updateEnvelopeRecipients = async ({
|
||||
});
|
||||
}
|
||||
|
||||
const sanitizedUpdateData = {
|
||||
...recipient,
|
||||
...(recipient.name !== undefined
|
||||
? {
|
||||
name: sanitizeRecipientName(recipient.name),
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
|
||||
return {
|
||||
originalRecipient,
|
||||
updateData: recipient,
|
||||
updateData: sanitizedUpdateData,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user