Monorepo for Tangled
at master 75 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 RepoDid string 20 Url string 21 Secret string 22 Active bool 23 Events []string // comma-separated event types 24 CreatedAt time.Time 25 UpdatedAt time.Time 26} 27 28// HasEvent checks if the webhook is subscribed to a specific event 29func (w *Webhook) HasEvent(event WebhookEvent) bool { 30 return slices.Contains(w.Events, string(event)) 31} 32 33type WebhookDelivery struct { 34 Id int64 35 WebhookId int64 36 Event string 37 DeliveryId string // UUID for tracking 38 Url string 39 RequestBody string 40 ResponseCode int 41 ResponseBody string 42 Success bool 43 CreatedAt time.Time 44} 45 46// WebhookPayload represents the webhook payload structure 47type WebhookPayload struct { 48 Ref string `json:"ref"` 49 Before string `json:"before"` 50 After string `json:"after"` 51 Repository WebhookRepository `json:"repository"` 52 Pusher WebhookUser `json:"pusher"` 53} 54 55// WebhookRepository represents repository information in webhook payload 56type WebhookRepository struct { 57 Name string `json:"name"` 58 FullName string `json:"full_name"` 59 Description string `json:"description"` 60 Fork bool `json:"fork"` 61 HtmlUrl string `json:"html_url"` 62 CloneUrl string `json:"clone_url"` 63 SshUrl string `json:"ssh_url"` 64 Website string `json:"website,omitempty"` 65 StarsCount int `json:"stars_count,omitempty"` 66 OpenIssues int `json:"open_issues_count,omitempty"` 67 CreatedAt string `json:"created_at"` 68 UpdatedAt string `json:"updated_at"` 69 Owner WebhookUser `json:"owner"` 70} 71 72// WebhookUser represents user information in webhook payload 73type WebhookUser struct { 74 Did string `json:"did"` 75}