diff options
author | techknowlogick <matti@mdranta.net> | 2019-04-18 22:45:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-18 22:45:02 -0400 |
commit | 56da256853001cf3538b8d4ae99798e084935a90 (patch) | |
tree | cdbd686d31750aa89365635eb96705c5a9fc1efc /models/webhook.go | |
parent | 6dbd26185203d464c4a4e32e7af04a34f37ae4f2 (diff) | |
download | gitea-56da256853001cf3538b8d4ae99798e084935a90.tar.gz gitea-56da256853001cf3538b8d4ae99798e084935a90.zip |
Telegram webhook (#4227)
Diffstat (limited to 'models/webhook.go')
-rw-r--r-- | models/webhook.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/models/webhook.go b/models/webhook.go index eb22e95975..8db281a15c 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -145,6 +145,15 @@ func (w *Webhook) GetDiscordHook() *DiscordMeta { 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) @@ -456,6 +465,7 @@ const ( GITEA DISCORD DINGTALK + TELEGRAM ) var hookTaskTypes = map[string]HookTaskType{ @@ -464,6 +474,7 @@ var hookTaskTypes = map[string]HookTaskType{ "slack": SLACK, "discord": DISCORD, "dingtalk": DINGTALK, + "telegram": TELEGRAM, } // ToHookTaskType returns HookTaskType by given name. @@ -484,6 +495,8 @@ func (t HookTaskType) Name() string { return "discord" case DINGTALK: return "dingtalk" + case TELEGRAM: + return "telegram" } return "" } @@ -657,6 +670,11 @@ func prepareWebhook(e Engine, w *Webhook, repo *Repository, event HookEventType, if err != nil { return fmt.Errorf("GetDingtalkPayload: %v", err) } + case TELEGRAM: + payloader, err = GetTelegramPayload(p, event, w.Meta) + if err != nil { + return fmt.Errorf("GetTelegramPayload: %v", err) + } default: p.SetSecret(w.Secret) payloader = p |