(client, guildId, userId, action, metadata = {})
| 595 | } |
| 596 | |
| 597 | function logVerificationAction(client, guildId, userId, action, metadata = {}) { |
| 598 | if (!shouldLogVerifications) { |
| 599 | return; |
| 600 | } |
| 601 | |
| 602 | const sanitizedMetadata = sanitizeAuditMetadata(metadata); |
| 603 | |
| 604 | logger.info('Verification action', { |
| 605 | guildId, |
| 606 | userId, |
| 607 | action, |
| 608 | timestamp: new Date().toISOString(), |
| 609 | metadata: sanitizedMetadata |
| 610 | }); |
| 611 | |
| 612 | if (!shouldKeepAuditTrail) { |
| 613 | return; |
| 614 | } |
| 615 | |
| 616 | const moderatorId = metadata.moderatorId || metadata.removedBy || null; |
| 617 | const source = metadata.source || null; |
| 618 | |
| 619 | void insertVerificationAudit({ |
| 620 | guildId, |
| 621 | userId, |
| 622 | action, |
| 623 | source, |
| 624 | moderatorId, |
| 625 | metadata: sanitizedMetadata, |
| 626 | createdAt: new Date().toISOString() |
| 627 | }); |
| 628 | } |
| 629 | |
| 630 | function sanitizeAuditMetadata(metadata = {}) { |
| 631 | try { |
no test coverage detected