Files
warmbly/internal/app/audit/noop.go
T
Matthew Meszaros e0ced97ba1 feat: add organization audit trail
Move audit logs into org-scoped Postgres storage, wire audit events across backend handlers, and surface actor details in the dashboard activity log.

Add realtime audit invalidation and retention pruning so the trail stays current and bounded.
2026-06-01 04:23:00 +02:00

46 lines
1.3 KiB
Go

package audit
import (
"context"
"time"
"github.com/google/uuid"
"github.com/warmbly/warmbly/internal/errx"
"github.com/warmbly/warmbly/internal/models"
)
// NoOpService is an AuditService that discards every call. It exists so
// handlers can call h.AuditService unconditionally without the embedded
// interface being nil — calling a method on a nil interface panics with a
// runtime nil-pointer deref, which the API would surface as a generic 500.
//
// The real persistence-backed service (NewService) is wired in
// cmd/backend/main.go; this remains as a safe fallback for tests or any
// entrypoint that has no database.
type NoOpService struct{}
func NewNoOpService() AuditService { return &NoOpService{} }
func (s *NoOpService) Log(_ context.Context, _ *models.CreateAuditLog) error {
return nil
}
func (s *NoOpService) LogAction(
_ context.Context,
_, _ uuid.UUID,
_ models.AuditAction,
_ models.AuditEntityType,
_ *uuid.UUID,
_, _ string,
_, _ map[string]string,
) {
}
func (s *NoOpService) Search(_ context.Context, _ *models.AuditLogSearch) (*models.AuditLogsResult, *errx.Error) {
return &models.AuditLogsResult{Data: []models.AuditLog{}}, nil
}
func (s *NoOpService) Prune(_ context.Context, _ time.Duration) (int64, error) {
return 0, nil
}