1
0
Fork 0
forked from forgejo/forgejo

Move more webhook codes from models to webhook module (#8802)

* Move more webhook codes from models to webhook module
This commit is contained in:
Lunny Xiao 2019-11-04 06:13:25 +08:00 committed by zeripath
parent 491887d441
commit a966a0298e
12 changed files with 145 additions and 135 deletions

View file

@ -118,33 +118,6 @@ func (w *Webhook) AfterLoad() {
}
}
// GetSlackHook returns slack metadata
func (w *Webhook) GetSlackHook() *SlackMeta {
s := &SlackMeta{}
if err := json.Unmarshal([]byte(w.Meta), s); err != nil {
log.Error("webhook.GetSlackHook(%d): %v", w.ID, err)
}
return s
}
// GetDiscordHook returns discord metadata
func (w *Webhook) GetDiscordHook() *DiscordMeta {
s := &DiscordMeta{}
if err := json.Unmarshal([]byte(w.Meta), s); err != nil {
log.Error("webhook.GetDiscordHook(%d): %v", w.ID, err)
}
return s
}
// GetTelegramHook returns telegram metadata
func (w *Webhook) GetTelegramHook() *TelegramMeta {
s := &TelegramMeta{}
if err := json.Unmarshal([]byte(w.Meta), s); err != nil {
log.Error("webhook.GetTelegramHook(%d): %v", w.ID, err)
}
return s
}
// History returns history of webhook by given conditions.
func (w *Webhook) History(page int) ([]*HookTask, error) {
return HookTasks(w.ID, page)