summaryrefslogtreecommitdiffstats
path: root/models/webhook.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/webhook.go')
-rw-r--r--models/webhook.go18
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