From cd2faaa02eb8d71a28fa5bf1c5bf766b373072f6 Mon Sep 17 00:00:00 2001 From: Samuel Pua Date: Sun, 29 May 2022 00:22:21 +0800 Subject: [PATCH] Fix(Webhook): HostURL for generation --- Jenkinsfile | 2 ++ backend/internal/webhookeverything/main.go | 3 ++- .../internal/webhookeverything/routegencontrollertelegram.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c05d565..6817d90 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,7 @@ pipeline { DB_NAME = credentials("DB_NAME") DB_SSL = credentials("DB_SSL") TELEGRAM_API_KEY = credentials("TELEGRAM_API_KEY") + HOST_URL = credentials("HOST_URL") } stages { @@ -25,6 +26,7 @@ pipeline { sh 'echo DB_NAME=$DB_NAME >> .env' sh 'echo DB_SSL=$DB_SSL >> .env' sh 'echo TELEGRAM_API_KEY=$TELEGRAM_API_KEY >> .env' + sh 'echo HOST_URL=$HOST_URL >> .env' echo 'Clearing Git directory' sh 'rm -rf ./.git' } diff --git a/backend/internal/webhookeverything/main.go b/backend/internal/webhookeverything/main.go index af67fa7..a113b66 100644 --- a/backend/internal/webhookeverything/main.go +++ b/backend/internal/webhookeverything/main.go @@ -12,13 +12,14 @@ import ( type Env struct { DB *gorm.DB TelegramEnv *telegrampackage.Env - HostUrl string + HostURL string } func WebhookEverythingRoutes(db *gorm.DB, telegramEnv *telegrampackage.Env, hostURL string) chi.Router { var env Env env.DB = db env.TelegramEnv = telegramEnv + env.HostURL = hostURL // Seed random rand.Seed(time.Now().UnixNano()) diff --git a/backend/internal/webhookeverything/routegencontrollertelegram.go b/backend/internal/webhookeverything/routegencontrollertelegram.go index e0ca30c..16a492d 100644 --- a/backend/internal/webhookeverything/routegencontrollertelegram.go +++ b/backend/internal/webhookeverything/routegencontrollertelegram.go @@ -13,7 +13,7 @@ func (env *Env) registerWebhook(shortCode string, text string) (bool, *string) { commandSplitted := telegrampackage.ParseTelegramBotCommand(text) if len(commandSplitted) > 0 && commandSplitted[0] == "/register-webhook" { newWebhookID := genWebhookCode(6) - baseURL, _ := url.Parse(env.HostUrl) + baseURL, _ := url.Parse(env.HostURL) baseURL.Path = path.Join(baseURL.Path, "webhook") baseURL.Path = path.Join(baseURL.Path, "routes") baseURL.Path = path.Join(baseURL.Path, newWebhookID)