/
webhook.go
58 lines (49 loc) · 2.59 KB
/
webhook.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package popltypes
import (
"time"
"github.com/infinitybotlist/eureka/dovewing/dovetypes"
"github.com/jackc/pgx/v5/pgtype"
)
type WebhookType = string
const (
WebhookTypeText WebhookType = "text"
WebhookTypeNumber WebhookType = "number"
WebhookTypeChangeset WebhookType = "changeset"
)
// @ci table=webhook_logs
//
// Webhook log
type WebhookLogEntry struct {
ID pgtype.UUID `db:"id" json:"id" description:"The ID of the webhook log."`
TargetID string `db:"target_id" json:"target_id" description:"The target ID."`
TargetType string `db:"target_type" json:"target_type" description:"The target type (bot/team etc.)."`
UserID string `db:"user_id" json:"-"`
User *dovetypes.PlatformUser `db:"-" json:"user" description:"User ID the webhook is intended for" ci:"internal"` // Must be parsed internally
URL string `db:"url" json:"url" description:"The URL of the webhook."`
Data map[string]any `db:"data" json:"data" description:"The data of the webhook."`
Response pgtype.Text `db:"response" json:"response" description:"The response of the webhook request."`
CreatedAt time.Time `db:"created_at" json:"created_at" description:"The time when the webhook was created."`
State string `db:"state" json:"state" description:"The state of the webhook."`
Tries int `db:"tries" json:"tries" description:"The number of send tries attempted on this webhook."`
LastTry time.Time `db:"last_try" json:"last_try" description:"The time of the last send try."`
BadIntent bool `db:"bad_intent" json:"bad_intent" description:"Whether the webhook was sent with bad intent."`
StatusCode int `db:"status_code" json:"status_code" description:"The status code of the webhook request."`
}
type PatchWebhook struct {
WebhookURL string `json:"webhook_url"`
WebhookSecret string `json:"webhook_secret"`
Clear bool `json:"clear"`
}
type GetTestWebhookMeta struct {
Types []TestWebhookType `json:"data"`
}
type TestWebhookType struct {
Type string `json:"type" description:"The type of webhook to test."`
Data []TestWebhookVariables
}
type TestWebhookVariables struct {
ID string `json:"id" description:"The ID of the variable."`
Name string `json:"name" description:"The name of the variable."`
Value string `json:"value" description:"The default value of the variable."`
Type WebhookType `json:"type" description:"The type of the variable."`
}