forked from gitea/gitea
1
0
Fork 0

Mirror fix on #242

This commit is contained in:
Unknown 2014-06-08 04:54:52 -04:00
parent a80d8d96fa
commit 1f58d6f5d9
1 changed files with 7 additions and 4 deletions

View File

@ -43,6 +43,7 @@ type Webhook struct {
IsActive bool IsActive bool
} }
// GetEvent handles conversion from Events to HookEvent.
func (w *Webhook) GetEvent() { func (w *Webhook) GetEvent() {
w.HookEvent = &HookEvent{} w.HookEvent = &HookEvent{}
if err := json.Unmarshal([]byte(w.Events), w.HookEvent); err != nil { 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 { func (w *Webhook) UpdateEvent() error {
data, err := json.Marshal(w.HookEvent) data, err := json.Marshal(w.HookEvent)
w.Events = string(data) w.Events = string(data)
return err return err
} }
// HasPushEvent returns true if hook enbaled push event.
func (w *Webhook) HasPushEvent() bool { func (w *Webhook) HasPushEvent() bool {
if w.PushOnly { if w.PushOnly {
return true return true
@ -115,7 +118,7 @@ func DeleteWebhook(hookId int64) error {
type HookTaskType int type HookTaskType int
const ( const (
WEBHOOK = iota + 1 WEBHOOK HookTaskType = iota + 1
SERVICE SERVICE
) )
@ -142,7 +145,7 @@ type PayloadRepo struct {
Private bool `json:"private"` Private bool `json:"private"`
} }
// Payload represents payload information of hook. // Payload represents a payload information of hook.
type Payload struct { type Payload struct {
Secret string `json:"secret"` Secret string `json:"secret"`
Ref string `json:"ref"` Ref string `json:"ref"`
@ -151,10 +154,10 @@ type Payload struct {
Pusher *PayloadAuthor `json:"pusher"` Pusher *PayloadAuthor `json:"pusher"`
} }
// HookTask represents hook task. // HookTask represents a hook task.
type HookTask struct { type HookTask struct {
Id int64 Id int64
Type int Type HookTaskType
Url string Url string
*Payload `xorm:"-"` *Payload `xorm:"-"`
PayloadContent string `xorm:"TEXT"` PayloadContent string `xorm:"TEXT"`