Monorepo for Tangled
at 74318eac9fdd72cf69e916276814351931ed0dcb 74 lines 2.0 kB view raw
1package models 2 3import ( 4 "slices" 5 "time" 6 7 "github.com/bluesky-social/indigo/atproto/syntax" 8) 9 10type WebhookEvent string 11 12const ( 13 WebhookEventPush WebhookEvent = "push" 14) 15 16type Webhook struct { 17 Id int64 18 RepoAt syntax.ATURI 19 Url string 20 Secret string 21 Active bool 22 Events []string // comma-separated event types 23 CreatedAt time.Time 24 UpdatedAt time.Time 25} 26 27// HasEvent checks if the webhook is subscribed to a specific event 28func (w *Webhook) HasEvent(event WebhookEvent) bool { 29 return slices.Contains(w.Events, string(event)) 30} 31 32type WebhookDelivery struct { 33 Id int64 34 WebhookId int64 35 Event string 36 DeliveryId string // UUID for tracking 37 Url string 38 RequestBody string 39 ResponseCode int 40 ResponseBody string 41 Success bool 42 CreatedAt time.Time 43} 44 45// WebhookPayload represents the webhook payload structure 46type WebhookPayload struct { 47 Ref string `json:"ref"` 48 Before string `json:"before"` 49 After string `json:"after"` 50 Repository WebhookRepository `json:"repository"` 51 Pusher WebhookUser `json:"pusher"` 52} 53 54// WebhookRepository represents repository information in webhook payload 55type WebhookRepository struct { 56 Name string `json:"name"` 57 FullName string `json:"full_name"` 58 Description string `json:"description"` 59 Fork bool `json:"fork"` 60 HtmlUrl string `json:"html_url"` 61 CloneUrl string `json:"clone_url"` 62 SshUrl string `json:"ssh_url"` 63 Website string `json:"website,omitempty"` 64 StarsCount int `json:"stars_count,omitempty"` 65 OpenIssues int `json:"open_issues_count,omitempty"` 66 CreatedAt string `json:"created_at"` 67 UpdatedAt string `json:"updated_at"` 68 Owner WebhookUser `json:"owner"` 69} 70 71// WebhookUser represents user information in webhook payload 72type WebhookUser struct { 73 Did string `json:"did"` 74}