feat: add API endpoint to reject documents on behalf of recipients (#3007)

Programmatically record an external rejection on behalf of a recipient
who declined outside the platform. Flags the rejection as external in
the audit log, optionally attributes it to a specific team member via
actAsEmail, and enforces team membership and document visibility.
This commit is contained in:
Lucas Smith
2026-06-22 21:59:07 +10:00
committed by GitHub
parent 2f24a8eab2
commit f2525ae95b
8 changed files with 623 additions and 6 deletions
+25 -5
View File
@@ -509,11 +509,31 @@ export const formatDocumentAuditLogAction = (i18n: I18n, auditLog: TDocumentAudi
user: msg`${user} completed their task`,
}));
})
.with({ type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_RECIPIENT_REJECTED }, () => ({
anonymous: msg`Recipient rejected the document`,
you: msg`You rejected the document`,
user: msg`${user} rejected the document`,
}))
.with({ type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_RECIPIENT_REJECTED }, ({ data }) => {
if (data.isExternal) {
const onBehalfOf = data.onBehalfOfUserName || data.onBehalfOfUserEmail;
if (onBehalfOf) {
return {
anonymous: msg`The document was rejected externally by ${onBehalfOf} on behalf of the recipient`,
you: msg`The document was rejected externally by ${onBehalfOf} on behalf of the recipient`,
user: msg`The document was rejected externally by ${onBehalfOf} on behalf of ${user}`,
};
}
return {
anonymous: msg`Recipient rejected the document externally`,
you: msg`The document was rejected externally on behalf of the recipient`,
user: msg`The document was rejected externally on behalf of ${user}`,
};
}
return {
anonymous: msg`Recipient rejected the document`,
you: msg`You rejected the document`,
user: msg`${user} rejected the document`,
};
})
.with({ type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_ACCESS_AUTH_2FA_REQUESTED }, () => ({
anonymous: msg`Recipient requested a 2FA token for the document`,
you: msg`You requested a 2FA token for the document`,