mirror of
https://github.com/warmbly/warmbly.git
synced 2026-11-28 08:05:45 +00:00
48 lines
1.3 KiB
Go
48 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) WireWebhookDispatcher(_ WebhookDispatcher) {}
|
|
|
|
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
|
|
}
|