(old, newVal T, fn func(T) R, auditAction database.AuditAction)
| 627 | } |
| 628 | |
| 629 | func either[T Auditable, R any](old, newVal T, fn func(T) R, auditAction database.AuditAction) R { |
| 630 | switch { |
| 631 | case ResourceID(newVal) != uuid.Nil: |
| 632 | return fn(newVal) |
| 633 | case ResourceID(old) != uuid.Nil: |
| 634 | return fn(old) |
| 635 | case auditAction == database.AuditActionLogin || auditAction == database.AuditActionLogout: |
| 636 | // If the request action is a login or logout, we always want to audit it even if |
| 637 | // there is no diff. See the comment in audit.InitRequest for more detail. |
| 638 | return fn(old) |
| 639 | default: |
| 640 | panic("both old and new are nil") |
| 641 | } |
| 642 | } |
no test coverage detected