Merge pull request #31 from DmitryZagorulko/master
improve translate, jenkinsfile, credentials
This commit is contained in:
commit
aedbfd1b6a
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -36,7 +36,7 @@ pipeline {
|
||||
|
||||
stage('Docker Images') {
|
||||
when {
|
||||
branch 'master'
|
||||
branch 'release'
|
||||
}
|
||||
steps {
|
||||
withCredentials([usernamePassword(
|
||||
|
@ -25,7 +25,3 @@ config_aws:
|
||||
bucket: ~
|
||||
folder_name: ~
|
||||
content_type: image/jpeg
|
||||
|
||||
credentials:
|
||||
- "/api/integration-modules/{code}"
|
||||
- "/api/integration-modules/{code}/edit"
|
||||
|
@ -25,7 +25,3 @@ config_aws:
|
||||
bucket: ~
|
||||
folder_name: ~
|
||||
content_type: image/jpeg
|
||||
|
||||
credentials:
|
||||
- "/api/integration-modules/{code}"
|
||||
- "/api/integration-modules/{code}/edit"
|
||||
|
@ -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"`
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
11
src/utils.go
11
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 {
|
||||
|
@ -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)))
|
||||
}
|
||||
|
@ -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]"
|
||||
|
@ -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]"
|
||||
|
@ -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: "[аудио файл]"
|
||||
|
Loading…
Reference in New Issue
Block a user