mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
fix: audit logs
This commit is contained in:
@ -335,6 +335,16 @@ export const DocumentHistorySheet = ({
|
||||
]}
|
||||
/>
|
||||
))
|
||||
.with({ type: DOCUMENT_AUDIT_LOG_TYPE.SELF_SIGN }, ({ data }) => (
|
||||
<DocumentHistorySheetChanges
|
||||
values={[
|
||||
{
|
||||
key: 'Signed by',
|
||||
value: data.recipientEmail,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
))
|
||||
.with(
|
||||
{ type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_VISIBILITY_UPDATED },
|
||||
({ data }) => (
|
||||
|
||||
@ -122,12 +122,16 @@ export const selfSignDocument = async ({
|
||||
if (document.status === DocumentStatus.DRAFT) {
|
||||
await tx.documentAuditLog.create({
|
||||
data: createDocumentAuditLogData({
|
||||
// todo: use a different audit log type
|
||||
type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_SENT,
|
||||
type: DOCUMENT_AUDIT_LOG_TYPE.SELF_SIGN,
|
||||
documentId: document.id,
|
||||
requestMetadata,
|
||||
user,
|
||||
data: {},
|
||||
data: {
|
||||
recipientId: document.Recipient[0].id,
|
||||
recipientEmail: document.Recipient[0].email,
|
||||
recipientName: document.Recipient[0].name,
|
||||
recipientRole: document.Recipient[0].role,
|
||||
},
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -13,6 +13,7 @@ import { ZRecipientActionAuthTypesSchema } from './document-auth';
|
||||
export const ZDocumentAuditLogTypeSchema = z.enum([
|
||||
// Document actions.
|
||||
'EMAIL_SENT',
|
||||
'SELF_SIGN',
|
||||
|
||||
// Document modification events.
|
||||
'FIELD_CREATED',
|
||||
@ -178,6 +179,14 @@ export const ZDocumentAuditLogEventEmailSentSchema = z.object({
|
||||
}),
|
||||
});
|
||||
|
||||
/**
|
||||
* Event: Self sign
|
||||
*/
|
||||
export const ZDocumentAuditLogSelfSignSchema = z.object({
|
||||
type: z.literal(DOCUMENT_AUDIT_LOG_TYPE.SELF_SIGN),
|
||||
data: ZBaseRecipientDataSchema,
|
||||
});
|
||||
|
||||
/**
|
||||
* Event: Document completed.
|
||||
*/
|
||||
@ -475,6 +484,7 @@ export const ZDocumentAuditLogBaseSchema = z.object({
|
||||
export const ZDocumentAuditLogSchema = ZDocumentAuditLogBaseSchema.and(
|
||||
z.union([
|
||||
ZDocumentAuditLogEventEmailSentSchema,
|
||||
ZDocumentAuditLogSelfSignSchema,
|
||||
ZDocumentAuditLogEventDocumentCompletedSchema,
|
||||
ZDocumentAuditLogEventDocumentCreatedSchema,
|
||||
ZDocumentAuditLogEventDocumentDeletedSchema,
|
||||
|
||||
@ -364,6 +364,10 @@ export const formatDocumentAuditLogAction = (auditLog: TDocumentAuditLog, userId
|
||||
anonymous: `Email ${data.isResending ? 'resent' : 'sent'}`,
|
||||
identified: `${data.isResending ? 'resent' : 'sent'} an email to ${data.recipientEmail}`,
|
||||
}))
|
||||
.with({ type: DOCUMENT_AUDIT_LOG_TYPE.SELF_SIGN }, () => ({
|
||||
anonymous: "You've signed the document",
|
||||
identified: 'signed the document',
|
||||
}))
|
||||
.with({ type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_COMPLETED }, () => {
|
||||
// Clear the prefix since this should be considered an 'anonymous' event.
|
||||
prefix = '';
|
||||
|
||||
Reference in New Issue
Block a user