diff --git a/Jenkinsfile b/Jenkinsfile
index 8d4862e..8906707 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -36,7 +36,7 @@ pipeline {
stage('Docker Images') {
when {
- branch 'master'
+ branch 'release'
}
steps {
withCredentials([usernamePassword(
diff --git a/config.yml.dist b/config.yml.dist
index 17c5134..1ea6923 100644
--- a/config.yml.dist
+++ b/config.yml.dist
@@ -25,7 +25,3 @@ config_aws:
bucket: ~
folder_name: ~
content_type: image/jpeg
-
-credentials:
- - "/api/integration-modules/{code}"
- - "/api/integration-modules/{code}/edit"
diff --git a/config_test.yml.dist b/config_test.yml.dist
index 034613a..f49d041 100644
--- a/config_test.yml.dist
+++ b/config_test.yml.dist
@@ -25,7 +25,3 @@ config_aws:
bucket: ~
folder_name: ~
content_type: image/jpeg
-
-credentials:
- - "/api/integration-modules/{code}"
- - "/api/integration-modules/{code}/edit"
diff --git a/src/config.go b/src/config.go
index 220901a..6fdedda 100644
--- a/src/config.go
+++ b/src/config.go
@@ -17,7 +17,6 @@ type TransportConfig struct {
Debug bool `yaml:"debug"`
UpdateInterval int `yaml:"update_interval"`
ConfigAWS ConfigAWS `yaml:"config_aws"`
- Credentials []string `yaml:"credentials"`
TransportInfo TransportInfo `yaml:"transport_info"`
}
diff --git a/src/main.go b/src/main.go
index cc880dd..4bd042b 100644
--- a/src/main.go
+++ b/src/main.go
@@ -2,6 +2,7 @@ package main
import (
"os"
+ "regexp"
"github.com/jessevdk/go-flags"
@@ -20,6 +21,7 @@ var (
options Options
parser = flags.NewParser(&options, flags.Default)
tokenCounter uint32
+ rx = regexp.MustCompile(`/+$`)
)
func main() {
diff --git a/src/run.go b/src/run.go
index 0c2b733..3032243 100644
--- a/src/run.go
+++ b/src/run.go
@@ -3,7 +3,6 @@ package main
import (
"os"
"os/signal"
- "regexp"
"syscall"
"github.com/getsentry/raven-go"
@@ -106,7 +105,6 @@ func createHTMLRender() multitemplate.Renderer {
func checkAccountForRequest() gin.HandlerFunc {
return func(c *gin.Context) {
- rx := regexp.MustCompile(`/+$`)
ra := rx.ReplaceAllString(c.Query("account"), ``)
p := Connection{
APIURL: ra,
@@ -143,6 +141,7 @@ func checkConnectionForRequest() gin.HandlerFunc {
return
}
+ conn.APIURL = rx.ReplaceAllString(conn.APIURL, ``)
c.Set("connection", conn)
}
}
diff --git a/src/utils.go b/src/utils.go
index 18fd9ce..b89f4d5 100644
--- a/src/utils.go
+++ b/src/utils.go
@@ -17,6 +17,13 @@ import (
"github.com/retailcrm/api-client-go/v5"
)
+var (
+ credentialsTransport = []string{
+ "/api/integration-modules/{code}",
+ "/api/integration-modules/{code}/edit",
+ }
+)
+
// GenerateToken function
func GenerateToken() string {
c := atomic.AddUint32(&tokenCounter, 1)
@@ -55,8 +62,8 @@ func getAPIClient(url, key string) (*v5.Client, error, int) {
}
func checkCredentials(credential []string) []string {
- rc := make([]string, len(config.Credentials))
- copy(rc, config.Credentials)
+ rc := make([]string, len(credentialsTransport))
+ copy(rc, credentialsTransport)
for _, vc := range credential {
for kn, vn := range rc {
diff --git a/src/validator.go b/src/validator.go
index b44c17b..a615259 100644
--- a/src/validator.go
+++ b/src/validator.go
@@ -8,6 +8,8 @@ import (
"gopkg.in/go-playground/validator.v8"
)
+var regCommandName = regexp.MustCompile(`https://?[\da-z.-]+\.(retailcrm\.(ru|pro)|ecomlogic\.com)`)
+
func setValidation() {
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
v.RegisterValidation("validatecrmurl", validateCrmURL)
@@ -18,7 +20,5 @@ func validateCrmURL(
v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
) bool {
- regCommandName := regexp.MustCompile(`https://?[\da-z.-]+\.(retailcrm\.(ru|pro)|ecomlogic\.com)`)
-
return regCommandName.Match([]byte(field.Interface().(string)))
}
diff --git a/translate/translate.en.yml b/translate/translate.en.yml
index fcb6b33..467fb28 100644
--- a/translate/translate.en.yml
+++ b/translate/translate.en.yml
@@ -30,7 +30,7 @@ missing_credentials: "Required methods: {{.Credentials}}"
error_activity_mg: Check if the integration with MessageGateway is enabled in retailCRM settings
info_bot: "If you have a problem with connecting a bot, please, refer to the documentation"
crm_link: "retailCRM"
-doc_link: "документация"
+doc_link: "documentation"
sticker: "[sticker]"
audio: "[audio file]"
diff --git a/translate/translate.es.yml b/translate/translate.es.yml
index 9cb8efc..a6c276e 100644
--- a/translate/translate.es.yml
+++ b/translate/translate.es.yml
@@ -28,9 +28,9 @@ error_adding_bot: Error al añadir el bot
error_save: Error al guardar, contacte con el soporte técnico
missing_credentials: "Métodos requeridos: {{.Credenciales}}"
error_activity_mg: Revisar si la integración con MessageGateway está habilitada en Ajustes de retailCRM
-info_bot: "Si tiene dificultades para conectar el bot, por favor, consulte la documentación"
-crm_link: "retailCRM"
-doc_link: "documentación"
+info_bot: "Si tiene dificultades para conectar el bot, por favor, consulte la documentación"
+crm_link: "retailCRM"
+doc_link: "documentación"
sticker: "[etiqueta]"
audio: "[archivo de audio]"
diff --git a/translate/translate.ru.yml b/translate/translate.ru.yml
index 06201d1..37096fb 100644
--- a/translate/translate.ru.yml
+++ b/translate/translate.ru.yml
@@ -30,7 +30,7 @@ missing_credentials: "Необходимые методы: {{.Credentials}}"
error_activity_mg: Проверьте активность интеграции с MessageGateway в настройках retailCRM
info_bot: "Если у вас возникли трудности при подключении бота, изучите, пожалуйста, документацию"
crm_link: "retailCRM"
-doc_link: "документация"
+doc_link: "документация"
sticker: "[стикер]"
audio: "[аудио файл]"