From f86487432b3b5f2fd4e2bb0a2d737674d9a105a6 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 23 Dec 2023 12:17:20 +0100 Subject: [PATCH] [ACTIONS] on.schedule: create a new payload do not reuse the payload of the event that triggered the creation of the scheduled event. Create a new one instead that contains no other information than the event name in the action field ("schedule"). (cherry picked from commit 0b40ca1ea5e6b704bcb6c0d370a21f633facc7d6) --- modules/structs/hook.go | 10 ++++++++++ services/actions/notifier_helper.go | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/structs/hook.go b/modules/structs/hook.go index 0babe84410..e8944c1130 100644 --- a/modules/structs/hook.go +++ b/modules/structs/hook.go @@ -402,6 +402,16 @@ func (p *PullRequestPayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") } +type HookScheduleAction string + +const ( + HookScheduleCreated HookScheduleAction = "schedule" +) + +type SchedulePayload struct { + Action HookScheduleAction `json:"action"` +} + // ReviewPayload FIXME type ReviewPayload struct { Type string `json:"type"` diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index 0478efdf5e..b5c13a15dd 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -423,7 +423,11 @@ func handleSchedules( return nil } - p, err := json.Marshal(input.Payload) + payload := &api.SchedulePayload{ + Action: api.HookScheduleCreated, + } + + p, err := json.Marshal(payload) if err != nil { return fmt.Errorf("json.Marshal: %w", err) }