A target's settings move from the per-type JSON string in targets.config to columns: url, headers, timeout_seconds, forward_query, archive_expiry and archive_rotation. A column a type does not use stays empty. headers holds the header map as JSON text through GORM's JSON serializer, and archive_expiry holds a time.Duration, 0 meaning never. The forms check each setting once, with the same refusals and messages, and the edit form is filled from the columns, so the per-type config structs, their parsers and the "could not be read" branches are gone. A delivery task carries the six settings in place of the JSON string; tests check that each copy into a task, and back out of one, keeps all six. Model: opus-5-5
This commit was merged in pull request #554.
This commit is contained in:
+41
-24
@@ -105,12 +105,19 @@ type Task struct {
|
||||
WebhookID string
|
||||
EntrypointID string
|
||||
|
||||
TargetID string
|
||||
TargetName string
|
||||
TargetType database.TargetType
|
||||
TargetConfig string
|
||||
MaxAttempts int
|
||||
// The target's fields, as they were when the task was made.
|
||||
TargetID string
|
||||
TargetName string
|
||||
TargetType database.TargetType
|
||||
TargetURL string
|
||||
TargetHeaders map[string]string
|
||||
TimeoutSeconds int
|
||||
ForwardQuery bool
|
||||
ArchiveExpiry time.Duration
|
||||
ArchiveRotation string
|
||||
MaxAttempts int
|
||||
|
||||
// The event's fields.
|
||||
Method string
|
||||
RawQuery string
|
||||
Headers string
|
||||
@@ -1543,10 +1550,15 @@ func buildEventFromTask(task *Task) database.Event {
|
||||
|
||||
func buildTargetFromTask(task *Task) database.Target {
|
||||
target := database.Target{
|
||||
Name: task.TargetName,
|
||||
Type: task.TargetType,
|
||||
Config: task.TargetConfig,
|
||||
MaxAttempts: task.MaxAttempts,
|
||||
Name: task.TargetName,
|
||||
Type: task.TargetType,
|
||||
URL: task.TargetURL,
|
||||
Headers: task.TargetHeaders,
|
||||
TimeoutSeconds: task.TimeoutSeconds,
|
||||
ForwardQuery: task.ForwardQuery,
|
||||
ArchiveExpiry: task.ArchiveExpiry,
|
||||
ArchiveRotation: task.ArchiveRotation,
|
||||
MaxAttempts: task.MaxAttempts,
|
||||
}
|
||||
|
||||
target.ID = task.TargetID
|
||||
@@ -1825,21 +1837,26 @@ func buildRecoveryTask(
|
||||
}
|
||||
|
||||
return Task{
|
||||
DeliveryID: d.ID,
|
||||
EventID: d.EventID,
|
||||
WebhookID: webhookID,
|
||||
EntrypointID: event.EntrypointID,
|
||||
TargetID: target.ID,
|
||||
TargetName: target.Name,
|
||||
TargetType: target.Type,
|
||||
TargetConfig: target.Config,
|
||||
MaxAttempts: target.MaxAttempts,
|
||||
Method: event.Method,
|
||||
RawQuery: event.RawQuery,
|
||||
Headers: event.Headers,
|
||||
ContentType: event.ContentType,
|
||||
Body: bodyPtr,
|
||||
AttemptNum: attemptNum,
|
||||
DeliveryID: d.ID,
|
||||
EventID: d.EventID,
|
||||
WebhookID: webhookID,
|
||||
EntrypointID: event.EntrypointID,
|
||||
TargetID: target.ID,
|
||||
TargetName: target.Name,
|
||||
TargetType: target.Type,
|
||||
TargetURL: target.URL,
|
||||
TargetHeaders: target.Headers,
|
||||
TimeoutSeconds: target.TimeoutSeconds,
|
||||
ForwardQuery: target.ForwardQuery,
|
||||
ArchiveExpiry: target.ArchiveExpiry,
|
||||
ArchiveRotation: target.ArchiveRotation,
|
||||
MaxAttempts: target.MaxAttempts,
|
||||
Method: event.Method,
|
||||
RawQuery: event.RawQuery,
|
||||
Headers: event.Headers,
|
||||
ContentType: event.ContentType,
|
||||
Body: bodyPtr,
|
||||
AttemptNum: attemptNum,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user