feat: activity log producers

This commit is contained in:
fsylvain committed 2026-10-06 22:25:23 +02:00
1 parent 50b1649965
commit e37a46a027
93 files changed
+3396 -440

No files matched your search

@@ -1,7 +1,9 @@
package useCases
import (
"RenewCMS/internal/domain/audit"
"RenewCMS/internal/domain/update"
"context"
"time"
)
@@ -10,13 +12,27 @@ type CheckForUpdateUseCase struct {
store update.StatusStore
currentVersion string
now func() time.Time
recorder audit.Recorder
}
func NewCheckForUpdateUseCase(feed update.ReleaseFeed, store update.StatusStore, currentVersion string, now func() time.Time) *CheckForUpdateUseCase {
return &CheckForUpdateUseCase{feed: feed, store: store, currentVersion: currentVersion, now: now}
func NewCheckForUpdateUseCase(feed update.ReleaseFeed, store update.StatusStore, currentVersion string, now func() time.Time, recorder audit.Recorder) *CheckForUpdateUseCase {
return &CheckForUpdateUseCase{feed: feed, store: store, currentVersion: currentVersion, now: now, recorder: recorder}
}
func (c *CheckForUpdateUseCase) Check() (update.UpdateStatus, error) {
func (c *CheckForUpdateUseCase) Check(ctx context.Context) (update.UpdateStatus, error) {
event := audit.NewEvent(audit.ActionUpdateChecked, audit.CategorySystem)
status, err := c.check()
if err != nil {
recordFailure(ctx, c.recorder, event, err)
return update.UpdateStatus{}, err
}
event.Target = audit.ReleaseTarget(status.Latest)
event.Params = map[string]any{audit.ParamUpdateAvailable: status.Available}
c.recorder.Record(ctx, event)
return status, nil
}
func (c *CheckForUpdateUseCase) check() (update.UpdateStatus, error) {
release, err := c.feed.Latest()
if err != nil {
return update.UpdateStatus{}, err