1
0
mirror of synced 2024-11-22 04:26:01 +03:00

Merge pull request #31 from DmitryZagorulko/master

improve translate, jenkinsfile, credentials
This commit is contained in:
Alex Lushpai 2018-09-10 16:13:45 +03:00 committed by GitHub
commit aedbfd1b6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 20 additions and 21 deletions

2
Jenkinsfile vendored
View File

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

View File

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

View File

@ -25,7 +25,3 @@ config_aws:
bucket: ~
folder_name: ~
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"`
UpdateInterval int `yaml:"update_interval"`
ConfigAWS ConfigAWS `yaml:"config_aws"`
Credentials []string `yaml:"credentials"`
TransportInfo TransportInfo `yaml:"transport_info"`
}

View File

@ -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() {

View File

@ -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)
}
}

View File

@ -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 {

View File

@ -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)))
}

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
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>"
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]"
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
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 <a target='_blank' href='//www.retailcrm.es/docs/Users/Telegram'>documentación</a>"
crm_link: "<a href='//www.retailcrm.es' title='retailCRM'>retailCRM</a>"
doc_link: "<a href='https://www.retailcrm.es/docs' target='_blank'>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.pro' title='retailCRM'>retailCRM</a>"
doc_link: "<a href='//www.retailcrm.pro/docs' target='_blank'>documentación</a>"
sticker: "[etiqueta]"
audio: "[archivo de audio]"

View File

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