aboutsummaryrefslogtreecommitdiffstats
path: root/models/webhook.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-06-08 04:54:52 -0400
committerUnknown <joe2010xtmf@163.com>2014-06-08 04:54:52 -0400
commit1f58d6f5d912187653db442e17d20261fc970b7b (patch)
treefda4a9436fc16bf5a46ede2220038883a11585f7 /models/webhook.go
parenta80d8d96fa592fc357b0e3f94ccd114d71852557 (diff)
downloadgitea-1f58d6f5d912187653db442e17d20261fc970b7b.tar.gz
gitea-1f58d6f5d912187653db442e17d20261fc970b7b.zip
Mirror fix on #242
Diffstat (limited to 'models/webhook.go')
-rw-r--r--models/webhook.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/models/webhook.go b/models/webhook.go
index e68edc813d..ffd47c8f9b 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -43,6 +43,7 @@ type Webhook struct {
IsActive bool
}
+// GetEvent handles conversion from Events to HookEvent.
func (w *Webhook) GetEvent() {
w.HookEvent = &HookEvent{}
if err := json.Unmarshal([]byte(w.Events), w.HookEvent); err != nil {
@@ -50,12 +51,14 @@ func (w *Webhook) GetEvent() {
}
}
+// UpdateEvent handles conversion from HookEvent to Events.
func (w *Webhook) UpdateEvent() error {
data, err := json.Marshal(w.HookEvent)
w.Events = string(data)
return err
}
+// HasPushEvent returns true if hook enbaled push event.
func (w *Webhook) HasPushEvent() bool {
if w.PushOnly {
return true
@@ -115,7 +118,7 @@ func DeleteWebhook(hookId int64) error {
type HookTaskType int
const (
- WEBHOOK = iota + 1
+ WEBHOOK HookTaskType = iota + 1
SERVICE
)
@@ -142,7 +145,7 @@ type PayloadRepo struct {
Private bool `json:"private"`
}
-// Payload represents payload information of hook.
+// Payload represents a payload information of hook.
type Payload struct {
Secret string `json:"secret"`
Ref string `json:"ref"`
@@ -151,10 +154,10 @@ type Payload struct {
Pusher *PayloadAuthor `json:"pusher"`
}
-// HookTask represents hook task.
+// HookTask represents a hook task.
type HookTask struct {
Id int64
- Type int
+ Type HookTaskType
Url string
*Payload `xorm:"-"`
PayloadContent string `xorm:"TEXT"`