mirror of
https://github.com/documenso/documenso.git
synced 2026-08-23 23:02:22 +10:00
feat: gate next-signer dictation to single-recipient steps
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
import { EnvelopeType, RecipientRole } from '@prisma/client';
|
import { EnvelopeType } from '@prisma/client';
|
||||||
|
|
||||||
import { mapDocumentIdToSecondaryId } from '../../utils/envelope';
|
import { mapDocumentIdToSecondaryId } from '../../utils/envelope';
|
||||||
|
import { getDictatableNextRecipient } from '../../utils/recipient-groups';
|
||||||
|
|
||||||
export const getNextPendingRecipient = async ({
|
export const getNextPendingRecipient = async ({
|
||||||
documentId,
|
documentId,
|
||||||
@@ -16,33 +17,17 @@ export const getNextPendingRecipient = async ({
|
|||||||
type: EnvelopeType.DOCUMENT,
|
type: EnvelopeType.DOCUMENT,
|
||||||
secondaryId: mapDocumentIdToSecondaryId(documentId),
|
secondaryId: mapDocumentIdToSecondaryId(documentId),
|
||||||
},
|
},
|
||||||
// CC recipients are informational only and never take part in signing,
|
|
||||||
// so they must never be offered as the next pending recipient.
|
|
||||||
role: {
|
|
||||||
not: RecipientRole.CC,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
orderBy: [
|
|
||||||
{
|
|
||||||
signingOrder: {
|
|
||||||
sort: 'asc',
|
|
||||||
nulls: 'last',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'asc',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const currentIndex = recipients.findIndex((r) => r.id === currentRecipientId);
|
const nextRecipient = getDictatableNextRecipient({ recipients, currentRecipientId });
|
||||||
|
|
||||||
if (currentIndex === -1 || currentIndex === recipients.length - 1) {
|
if (!nextRecipient) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...recipients[currentIndex + 1],
|
...nextRecipient,
|
||||||
token: '',
|
token: '',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import {
|
|||||||
extractDocumentAuthMethods,
|
extractDocumentAuthMethods,
|
||||||
} from '../../utils/document-auth';
|
} from '../../utils/document-auth';
|
||||||
import { mapSecondaryIdToTemplateId } from '../../utils/envelope';
|
import { mapSecondaryIdToTemplateId } from '../../utils/envelope';
|
||||||
|
import { filterRecipientsInFirstSigningGroup } from '../../utils/recipient-groups';
|
||||||
import { getRecipientsWithMissingFields } from '../../utils/recipients';
|
import { getRecipientsWithMissingFields } from '../../utils/recipients';
|
||||||
import { sendDocument } from '../document/send-document';
|
import { sendDocument } from '../document/send-document';
|
||||||
import { validateFieldAuth } from '../document/validate-field-auth';
|
import { validateFieldAuth } from '../document/validate-field-auth';
|
||||||
@@ -694,7 +695,10 @@ export const createDocumentFromDirectTemplate = async ({
|
|||||||
orderBy: [{ signingOrder: { sort: 'asc', nulls: 'last' } }, { id: 'asc' }],
|
orderBy: [{ signingOrder: { sort: 'asc', nulls: 'last' } }, { id: 'asc' }],
|
||||||
});
|
});
|
||||||
|
|
||||||
const nextRecipient = pendingRecipients[0];
|
const nextGroup = filterRecipientsInFirstSigningGroup(pendingRecipients);
|
||||||
|
|
||||||
|
// Dictation only applies when the next step is a single recipient.
|
||||||
|
const nextRecipient = nextGroup.length === 1 ? nextGroup[0] : null;
|
||||||
|
|
||||||
if (nextRecipient) {
|
if (nextRecipient) {
|
||||||
auditLogsToCreate.push(
|
auditLogsToCreate.push(
|
||||||
|
|||||||
Reference in New Issue
Block a user