Make webhook work.

This commit is contained in:
Gucheng Wang
2021-11-07 23:53:17 +08:00
parent 87e6fb63e1
commit 30a2fdef37
6 changed files with 91 additions and 5 deletions

View File

@ -30,7 +30,7 @@ type Webhook struct {
ContentType string `xorm:"varchar(100)" json:"contentType"`
Events []string `xorm:"varchar(100)" json:"events"`
Organization string `xorm:"varchar(100)" json:"organization"`
Organization string `xorm:"varchar(100) index" json:"organization"`
}
func GetWebhookCount(owner string) int {
@ -62,6 +62,16 @@ func GetPaginationWebhooks(owner string, offset, limit int) []*Webhook {
return webhooks
}
func getWebhooksByOrganization(organization string) []*Webhook {
webhooks := []*Webhook{}
err := adapter.Engine.Desc("created_time").Find(&webhooks, &Webhook{Organization: organization})
if err != nil {
panic(err)
}
return webhooks
}
func getWebhook(owner string, name string) *Webhook {
if owner == "" || name == "" {
return nil