Skip to content

Commit

Permalink
[ACTIONS] on.schedule: create a new payload
Browse files Browse the repository at this point in the history
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)
(cherry picked from commit f864874)
(cherry picked from commit 4bd5d2e9d0c7987a9d7cce495509c8790dcdcd3a)
(cherry picked from commit d10830e238f35bcd0100a4de68d68b15402ec05a)
(cherry picked from commit 53f5a3aa911fb63689ef018fe583eeb03f248517)
(cherry picked from commit 9ed1487b73babe44d0b2855cc708184c55671ab0)
(cherry picked from commit 6a399788516523bc52778f9d9df7f283d5b2c6d6)
  • Loading branch information
earl-warren committed Feb 5, 2024
1 parent 33b1dec commit 41871ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions modules/structs/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
6 changes: 5 additions & 1 deletion services/actions/notifier_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,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)
}
Expand Down

0 comments on commit 41871ba

Please sign in to comment.