2024-10-31 17:55:42 -05:00
|
|
|
package audit
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"encoding/json"
|
|
|
|
|
|
2026-01-08 10:29:41 +04:00
|
|
|
"cdr.dev/slog/v3"
|
2024-10-31 17:55:42 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type BackgroundSubsystem string
|
|
|
|
|
|
|
|
|
|
const (
|
2026-04-24 14:18:28 +01:00
|
|
|
BackgroundSubsystemDormancy BackgroundSubsystem = "dormancy"
|
|
|
|
|
BackgroundSubsystemChatAutoArchive BackgroundSubsystem = "chat_auto_archive"
|
2024-10-31 17:55:42 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func BackgroundTaskFields(subsystem BackgroundSubsystem) map[string]string {
|
|
|
|
|
return map[string]string{
|
|
|
|
|
"automatic_actor": "coder",
|
|
|
|
|
"automatic_subsystem": string(subsystem),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func BackgroundTaskFieldsBytes(ctx context.Context, logger slog.Logger, subsystem BackgroundSubsystem) []byte {
|
|
|
|
|
af := BackgroundTaskFields(subsystem)
|
|
|
|
|
|
|
|
|
|
wriBytes, err := json.Marshal(af)
|
|
|
|
|
if err != nil {
|
2026-04-21 11:11:56 +01:00
|
|
|
logger.Error(ctx, "marshal additional fields for background audit", slog.Error(err))
|
2024-10-31 17:55:42 -05:00
|
|
|
return []byte("{}")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return wriBytes
|
|
|
|
|
}
|