1
0
mirror of synced 2024-11-25 05:06:03 +03:00

improve translate, jenkinsfile, credentials

This commit is contained in:
DmitryZagorulko 2018-09-10 14:50:18 +03:00
parent 1b83543749
commit f79f8e2f7c
11 changed files with 20 additions and 21 deletions

2
Jenkinsfile vendored
View File

@ -36,7 +36,7 @@ pipeline {
stage('Docker Images') { stage('Docker Images') {
when { when {
branch 'master' branch 'release'
} }
steps { steps {
withCredentials([usernamePassword( withCredentials([usernamePassword(

View File

@ -25,7 +25,3 @@ config_aws:
bucket: ~ bucket: ~
folder_name: ~ folder_name: ~
content_type: image/jpeg content_type: image/jpeg
credentials:
- "/api/integration-modules/{code}"
- "/api/integration-modules/{code}/edit"

View File

@ -25,7 +25,3 @@ config_aws:
bucket: ~ bucket: ~
folder_name: ~ folder_name: ~
content_type: image/jpeg content_type: image/jpeg
credentials:
- "/api/integration-modules/{code}"
- "/api/integration-modules/{code}/edit"

View File

@ -17,7 +17,6 @@ type TransportConfig struct {
Debug bool `yaml:"debug"` Debug bool `yaml:"debug"`
UpdateInterval int `yaml:"update_interval"` UpdateInterval int `yaml:"update_interval"`
ConfigAWS ConfigAWS `yaml:"config_aws"` ConfigAWS ConfigAWS `yaml:"config_aws"`
Credentials []string `yaml:"credentials"`
TransportInfo TransportInfo `yaml:"transport_info"` TransportInfo TransportInfo `yaml:"transport_info"`
} }

View File

@ -2,6 +2,7 @@ package main
import ( import (
"os" "os"
"regexp"
"github.com/jessevdk/go-flags" "github.com/jessevdk/go-flags"
@ -20,6 +21,7 @@ var (
options Options options Options
parser = flags.NewParser(&options, flags.Default) parser = flags.NewParser(&options, flags.Default)
tokenCounter uint32 tokenCounter uint32
rx = regexp.MustCompile(`/+$`)
) )
func main() { func main() {

View File

@ -3,7 +3,6 @@ package main
import ( import (
"os" "os"
"os/signal" "os/signal"
"regexp"
"syscall" "syscall"
"github.com/getsentry/raven-go" "github.com/getsentry/raven-go"
@ -106,7 +105,6 @@ func createHTMLRender() multitemplate.Renderer {
func checkAccountForRequest() gin.HandlerFunc { func checkAccountForRequest() gin.HandlerFunc {
return func(c *gin.Context) { return func(c *gin.Context) {
rx := regexp.MustCompile(`/+$`)
ra := rx.ReplaceAllString(c.Query("account"), ``) ra := rx.ReplaceAllString(c.Query("account"), ``)
p := Connection{ p := Connection{
APIURL: ra, APIURL: ra,
@ -143,6 +141,7 @@ func checkConnectionForRequest() gin.HandlerFunc {
return return
} }
conn.APIURL = rx.ReplaceAllString(conn.APIURL, ``)
c.Set("connection", conn) c.Set("connection", conn)
} }
} }

View File

@ -17,6 +17,13 @@ import (
"github.com/retailcrm/api-client-go/v5" "github.com/retailcrm/api-client-go/v5"
) )
var (
credentialsTransport = []string{
"/api/integration-modules/{code}",
"/api/integration-modules/{code}/edit",
}
)
// GenerateToken function // GenerateToken function
func GenerateToken() string { func GenerateToken() string {
c := atomic.AddUint32(&tokenCounter, 1) c := atomic.AddUint32(&tokenCounter, 1)
@ -55,8 +62,8 @@ func getAPIClient(url, key string) (*v5.Client, error, int) {
} }
func checkCredentials(credential []string) []string { func checkCredentials(credential []string) []string {
rc := make([]string, len(config.Credentials)) rc := make([]string, len(credentialsTransport))
copy(rc, config.Credentials) copy(rc, credentialsTransport)
for _, vc := range credential { for _, vc := range credential {
for kn, vn := range rc { for kn, vn := range rc {

View File

@ -8,6 +8,8 @@ import (
"gopkg.in/go-playground/validator.v8" "gopkg.in/go-playground/validator.v8"
) )
var regCommandName = regexp.MustCompile(`https://?[\da-z.-]+\.(retailcrm\.(ru|pro)|ecomlogic\.com)`)
func setValidation() { func setValidation() {
if v, ok := binding.Validator.Engine().(*validator.Validate); ok { if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
v.RegisterValidation("validatecrmurl", validateCrmURL) v.RegisterValidation("validatecrmurl", validateCrmURL)
@ -18,7 +20,5 @@ func validateCrmURL(
v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value, v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string, field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
) bool { ) bool {
regCommandName := regexp.MustCompile(`https://?[\da-z.-]+\.(retailcrm\.(ru|pro)|ecomlogic\.com)`)
return regCommandName.Match([]byte(field.Interface().(string))) return regCommandName.Match([]byte(field.Interface().(string)))
} }

View File

@ -30,7 +30,7 @@ missing_credentials: "Required methods: {{.Credentials}}"
error_activity_mg: Check if the integration with MessageGateway is enabled in retailCRM settings 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 <a target='_blank' href='//www.retailcrm.pro/docs/Users/Telegram'>documentation</a>" info_bot: "If you have a problem with connecting a bot, please, refer to the <a target='_blank' href='//www.retailcrm.pro/docs/Users/Telegram'>documentation</a>"
crm_link: "<a href='//www.retailcrm.pro' title='retailCRM'>retailCRM</a>" crm_link: "<a href='//www.retailcrm.pro' title='retailCRM'>retailCRM</a>"
doc_link: "<a href='https://www.retailcrm.pro/docs' target='_blank'>документация</a>" doc_link: "<a href='//www.retailcrm.pro/docs' target='_blank'>documentation</a>"
sticker: "[sticker]" sticker: "[sticker]"
audio: "[audio file]" audio: "[audio file]"

View File

@ -28,9 +28,9 @@ error_adding_bot: Error al añadir el bot
error_save: Error al guardar, contacte con el soporte técnico error_save: Error al guardar, contacte con el soporte técnico
missing_credentials: "Métodos requeridos: {{.Credenciales}}" missing_credentials: "Métodos requeridos: {{.Credenciales}}"
error_activity_mg: Revisar si la integración con MessageGateway está habilitada en Ajustes de retailCRM 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 <a target='_blank' href='//www.retailcrm.es/docs/Users/Telegram'>documentación</a>" info_bot: "Si tiene dificultades para conectar el bot, por favor, consulte la <a target='_blank' href='//www.retailcrm.pro/docs/Users/Telegram'>documentación</a>"
crm_link: "<a href='//www.retailcrm.es' title='retailCRM'>retailCRM</a>" crm_link: "<a href='//www.retailcrm.pro' title='retailCRM'>retailCRM</a>"
doc_link: "<a href='https://www.retailcrm.es/docs' target='_blank'>documentación</a>" doc_link: "<a href='//www.retailcrm.pro/docs' target='_blank'>documentación</a>"
sticker: "[etiqueta]" sticker: "[etiqueta]"
audio: "[archivo de audio]" audio: "[archivo de audio]"

View File

@ -30,7 +30,7 @@ missing_credentials: "Необходимые методы: {{.Credentials}}"
error_activity_mg: Проверьте активность интеграции с MessageGateway в настройках retailCRM error_activity_mg: Проверьте активность интеграции с MessageGateway в настройках retailCRM
info_bot: "Если у вас возникли трудности при подключении бота, изучите, пожалуйста, <a target='_blank' href='//www.retailcrm.ru/docs/Users/Telegram'>документацию</a>" info_bot: "Если у вас возникли трудности при подключении бота, изучите, пожалуйста, <a target='_blank' href='//www.retailcrm.ru/docs/Users/Telegram'>документацию</a>"
crm_link: "<a href='//www.retailcrm.ru' title='retailCRM'>retailCRM</a>" crm_link: "<a href='//www.retailcrm.ru' title='retailCRM'>retailCRM</a>"
doc_link: "<a href='https://www.retailcrm.ru/docs' target='_blank'>документация</a>" doc_link: "<a href='//www.retailcrm.ru/docs' target='_blank'>документация</a>"
sticker: "[стикер]" sticker: "[стикер]"
audio: "[аудио файл]" audio: "[аудио файл]"