示例#1
0
func GetAppWebHooks(c *gin.Context) {
	appKey := c.Param("app_key")
	apps, err := models.GetWebHooksByAppKey(nil, appKey)
	if err != nil {
		Error(c, SERVER_ERROR, err.Error())
		return
	}
	Success(c, apps)
}
示例#2
0
func TriggerWebHooks(m *models.ConfigUpdateHistory, app *models.App) {
	var globalHooks, appHooks []*models.WebHook
	globalHooks, _ = models.GetGlobalWebHooks(nil)
	appHooks, _ = models.GetWebHooksByAppKey(nil, app.Key)

	for _, hook := range append(globalHooks, appHooks...) {
		switch hook.Target {
		case models.WEBHOOK_TARGET_PUBU:
			sendNotificationToPubu(hook.URL, m, app)
		case models.WEBHOOK_TARGET_SLACK:
			sendNotificationToSlack(hook.URL, m, app)
		}
	}
}