| iomodo | b23799d | 2025-07-31 14:08:22 +0400 | [diff] [blame] | 1 | package app |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "github.com/iomodo/staff/git" |
| 7 | ) |
| 8 | |
| 9 | func (a *App) ProposalApproval(body []byte, signature string) error { |
| 10 | // Validate the webhook signature |
| 11 | if err := git.ValidateSignature(body, signature, a.config.GitHub.WebhookSecret); err != nil { |
| 12 | return fmt.Errorf("invalid webhook signature: %w", err) |
| 13 | } |
| 14 | |
| 15 | // Process the webhook payload |
| 16 | taskID, err := git.ProcessMergeWebhook(body, signature, a.config.GitHub.WebhookSecret) |
| 17 | if err != nil { |
| iomodo | 8acd08d | 2025-07-31 16:22:08 +0400 | [diff] [blame] | 18 | return fmt.Errorf("failed to process webhook: %w", err) |
| iomodo | b23799d | 2025-07-31 14:08:22 +0400 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | // Log the successful approval |
| 22 | a.logger.Info("Proposal approved via webhook", |
| 23 | "task_id", taskID, |
| 24 | ) |
| 25 | return nil |
| 26 | } |