Carry the event's receipt time into every delivery (closes #257)
All checks were successful
check / check (push) Successful in 3m59s
All checks were successful
check / check (push) Successful in 3m59s
Every Slack and Mattermost message the engine sent rendered a `*Timestamp:*` of `0001-01-01T00:00:00Z` while the stored event's `created_at` was correct. Both delivery paths reconstruct the event from the Task that carries it, and no Task carries a receipt time, so `FormatSlackMessage` formatted a zero `time.Time`. `Task` is not the place to fix it: it is built in three places, two of them on the receiver side, and a field there would have left the live first-attempt and retry paths still zero while only the restart recovery path came out correct. The stored row stays the single source of truth instead. `resolveEventBody` becomes `hydrateEvent` and reads `created_at` alongside the body, so every path that reconstructs an event gets the receipt time with it. A task that inlined its body previously never read the event row. It does now, and a read failure there is no longer fatal: the row can be reaped by retention while a queued delivery still holds its body, and such a delivery goes out with the timestamp unset rather than being dropped. A task with no inlined body still fails, as before.
This commit is contained in:
@@ -151,6 +151,16 @@ func (e *Engine) ExportProcessRetryTask(
|
||||
e.processRetryTask(ctx, task)
|
||||
}
|
||||
|
||||
// ExportEventForTask exposes the event reconstruction the delivery
|
||||
// paths run: buildEventFromTask followed by hydrateEvent.
|
||||
func (e *Engine) ExportEventForTask(
|
||||
webhookDB *gorm.DB, task *Task,
|
||||
) (database.Event, error) {
|
||||
return e.hydrateEvent(
|
||||
webhookDB, buildEventFromTask(task), task,
|
||||
)
|
||||
}
|
||||
|
||||
// ExportProcessDelivery exposes processDelivery.
|
||||
func (e *Engine) ExportProcessDelivery(
|
||||
ctx context.Context,
|
||||
|
||||
Reference in New Issue
Block a user