Signed-off-by: Anirudh Oppiliappan anirudh@tangled.org
-1
appview/db/db.go
-1
appview/db/db.go
···
608
608
create index if not exists idx_references_to_at on reference_links(to_at);
609
609
create index if not exists idx_webhooks_repo_at on webhooks(repo_at);
610
610
create index if not exists idx_webhook_deliveries_webhook_id on webhook_deliveries(webhook_id);
611
-
create index if not exists idx_webhook_deliveries_created_at on webhook_deliveries(created_at desc);
612
611
`)
613
612
if err != nil {
614
613
return nil, err
appview/db/webhooks.go
appview/db/webhooks.go
This file has not been changed.
+44
-1
appview/models/webhook.go
+44
-1
appview/models/webhook.go
···
1
1
package models
2
2
3
3
import (
4
+
"slices"
4
5
"time"
5
6
6
7
"github.com/bluesky-social/indigo/atproto/syntax"
7
8
)
8
9
10
+
type WebhookEvent string
11
+
12
+
const (
13
+
WebhookEventPush WebhookEvent = "push"
14
+
)
15
+
9
16
type Webhook struct {
10
17
Id int64
11
18
RepoAt syntax.ATURI
12
19
Url string
13
20
Secret string
14
21
Active bool
15
-
Events []string // e.g., ["push", "pull_request", "issues"]
22
+
Events []string // comma-separated event types
16
23
CreatedAt time.Time
17
24
UpdatedAt time.Time
18
25
}
19
26
27
+
// HasEvent checks if the webhook is subscribed to a specific event
28
+
func (w *Webhook) HasEvent(event WebhookEvent) bool {
29
+
return slices.Contains(w.Events, string(event))
30
+
}
31
+
20
32
type WebhookDelivery struct {
21
33
Id int64
22
34
WebhookId int64
···
29
41
Success bool
30
42
CreatedAt time.Time
31
43
}
44
+
45
+
// WebhookPayload represents the webhook payload structure
46
+
type 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
55
+
type 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
72
+
type WebhookUser struct {
73
+
Did string `json:"did"`
74
+
}
History
6 rounds
5 comments
anirudh.fi
submitted
#5
1 commit
expand
collapse
appview/{db,models}: webhook tables and crud ops
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
3/3 success
expand
collapse
expand 0 comments
pull request successfully merged
anirudh.fi
submitted
#4
1 commit
expand
collapse
appview/{db,models}: webhook tables and crud ops
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
3/3 success
expand
collapse
expand 0 comments
anirudh.fi
submitted
#3
1 commit
expand
collapse
appview/{db,models}: webhook tables and crud ops
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
3/3 success
expand
collapse
expand 3 comments
the db code needs to be updated accordingly to handle null strings, by reading into a sql.Null[string] and checking for s.Valid.
Oh, right...
anirudh.fi
submitted
#2
1 commit
expand
collapse
appview/{db,models}: webhook tables and crud ops
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
3/3 success
expand
collapse
anirudh.fi
submitted
#1
1 commit
expand
collapse
appview:{db,models}: webhook tables and crud ops
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
3/3 success
expand
collapse
expand 1 comment
- we dont need this index
- would be nice to make [this] more strongly typed, we could have an enum for this, like
type WebhookEvent stringwith more concrete variants
anirudh.fi
submitted
#0
1 commit
expand
collapse
appview:{db,models}: webhook tables and crud ops
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
@oppi.li, done.