diff --git a/Dockerfile b/Dockerfile index 4f24cb4..13eb6c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.9.3-stretch +FROM golang:1.11-stretch WORKDIR / ADD ./bin/transport / diff --git a/Makefile b/Makefile index cb21af6..f8a1515 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ test: deps fmt jenkins_test: deps @echo "==> Running tests (result in test-report.xml)" @go get -v -u github.com/jstemmer/go-junit-report - @go test ./... -v -cpu 2 -race | go-junit-report@v0.0.0-20180614143834-385fac0ced9a -set-exit-code > ./test-report.xml + @go test ./... -v -cpu 2 -race | /go/bin/go-junit-report -set-exit-code > ./test-report.xml fmt: @echo "==> Running gofmt" diff --git a/docker-compose-test.yml b/docker-compose-test.yml index 33f9776..cf789fc 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -11,7 +11,7 @@ services: - ${POSTGRES_ADDRESS:-127.0.0.1:5434}:${POSTGRES_PORT:-5432} mg_telegram_test: - image: golang:1.11beta3-stretch + image: golang:1.11-stretch working_dir: /mgtg user: ${UID:-1000}:${GID:-1000} environment: diff --git a/docker-compose.yml b/docker-compose.yml index 02e3670..a31ed0e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: - ${POSTGRES_ADDRESS:-127.0.0.1:5434}:${POSTGRES_PORT:-5432} mg_telegram: - image: golang:1.11beta3-stretch + image: golang:1.11-stretch working_dir: /mgtg user: ${UID:-1000}:${GID:-1000} environment: diff --git a/go.mod b/go.mod index ddf8911..8b6d5ac 100644 --- a/go.mod +++ b/go.mod @@ -2,18 +2,18 @@ module github.com/retailcrm/mg-transport-telegram require ( cloud.google.com/go v0.26.0 // indirect - github.com/Microsoft/go-winio v0.4.10 // indirect - github.com/aws/aws-sdk-go v1.15.18 + github.com/Microsoft/go-winio v0.4.11 // indirect + github.com/aws/aws-sdk-go v1.15.25 github.com/certifi/gocertifi v0.0.0-20180118203423-deb3ae2ef261 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/denisenkom/go-mssqldb v0.0.0-20180707235734-242fa5aa1b45 // indirect + github.com/denisenkom/go-mssqldb v0.0.0-20180824013952-8fac8b954edb // indirect github.com/docker/distribution v2.6.2+incompatible // indirect github.com/docker/docker v1.13.1 // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.3.3 // indirect github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 // indirect - github.com/getsentry/raven-go v0.0.0-20180801005657-7535a8fa2ace - github.com/gin-contrib/multitemplate v0.0.0-20180607024123-41d1d62d1df3 + github.com/getsentry/raven-go v0.0.0-20180827214142-a9457d81ec91 + github.com/gin-contrib/multitemplate v0.0.0-20180827023943-5799bbbb6dce github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 // indirect github.com/gin-gonic/gin v1.3.0 github.com/go-ini/ini v1.38.2 // indirect @@ -23,39 +23,38 @@ require ( github.com/golang/protobuf v1.2.0 // indirect github.com/google/go-cmp v0.2.0 // indirect github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 // indirect - github.com/gopherjs/gopherjs v0.0.0-20180820052304-89baedc74dd7 // indirect + github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c // indirect github.com/h2non/gock v1.0.9 github.com/jessevdk/go-flags v1.4.0 github.com/jinzhu/gorm v1.9.1 github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect github.com/jinzhu/now v0.0.0-20180511015916-ed742868f2ae // indirect github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect - github.com/json-iterator/go v0.0.0-20180806060727-1624edc4454b // indirect + github.com/json-iterator/go v1.1.5 // indirect github.com/jtolds/gls v4.2.1+incompatible // indirect github.com/kr/pretty v0.1.0 // indirect - github.com/kr/pty v1.1.2 // indirect github.com/lib/pq v1.0.0 // indirect - github.com/mattn/go-isatty v0.0.3 // indirect + github.com/mattn/go-isatty v0.0.4 // indirect github.com/mattn/go-sqlite3 v1.9.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v0.0.0-20180718012357-94122c33edd3 // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 // indirect github.com/nicksnyder/go-i18n/v2 v2.0.0-beta.5 github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/pkg/errors v0.8.0 github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/retailcrm/api-client-go v1.0.4 - github.com/retailcrm/mg-transport-api-client-go v1.1.2 + github.com/retailcrm/api-client-go v1.0.6 + github.com/retailcrm/mg-transport-api-client-go v1.1.4 github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf // indirect github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a // indirect - github.com/stevvooe/resumable v0.0.0-20170302213456-2aaf90b2ceea // indirect + github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 // indirect github.com/stretchr/testify v1.2.2 github.com/technoweenie/multipartstreamer v1.0.1 // indirect github.com/ugorji/go v1.1.1 // indirect - golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac // indirect - golang.org/x/net v0.0.0-20180821023952-922f4815f713 // indirect + golang.org/x/crypto v0.0.0-20180830192347-182538f80094 // indirect + golang.org/x/net v0.0.0-20180826012351-8a410e7b638d // indirect golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect - golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc // indirect + golang.org/x/sys v0.0.0-20180831094639-fa5fdf94c789 // indirect golang.org/x/text v0.3.0 google.golang.org/appengine v1.1.0 // indirect gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect diff --git a/go.sum b/go.sum index 9df65c5..e8edeae 100644 --- a/go.sum +++ b/go.sum @@ -2,16 +2,16 @@ cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.0 h1:e1/Ivsx3Z0FVTV0NSOv/aVgbUWyQuzj7DDnFblkRvsY= github.com/BurntSushi/toml v0.3.0/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Microsoft/go-winio v0.4.10 h1:NrhPZI+cp3Fjmm5t/PZkVuir43JIRLZG/PSKK7atSfw= -github.com/Microsoft/go-winio v0.4.10/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/aws/aws-sdk-go v1.15.18 h1:5rjkyy+mBc1CoSNnjCzGq0R+is4ghNDZEj/U6rM7rYk= -github.com/aws/aws-sdk-go v1.15.18/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= +github.com/Microsoft/go-winio v0.4.11 h1:zoIOcVf0xPN1tnMVbTtEdI+P8OofVk3NObnwOQ6nK2Q= +github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= +github.com/aws/aws-sdk-go v1.15.25 h1:n0+QZLTS5npWwIArmudXj0z6Tun7yEBFhbE1sRKR4M8= +github.com/aws/aws-sdk-go v1.15.25/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= github.com/certifi/gocertifi v0.0.0-20180118203423-deb3ae2ef261 h1:6/yVvBsKeAw05IUj4AzvrxaCnDjN4nUqKjW9+w5wixg= github.com/certifi/gocertifi v0.0.0-20180118203423-deb3ae2ef261/go.mod h1:GJKEexRPVJrBSOjoqN5VNOIKJ5Q3RViH6eu3puDRwx4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denisenkom/go-mssqldb v0.0.0-20180707235734-242fa5aa1b45 h1:UW8VerkZA1zCt3uWhQ2wbMae76OLn7s7Utz8wyKtJUk= -github.com/denisenkom/go-mssqldb v0.0.0-20180707235734-242fa5aa1b45/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc= +github.com/denisenkom/go-mssqldb v0.0.0-20180824013952-8fac8b954edb h1:VHrAAPJHYRUA1DtueJ2IuAcAIYLXYU009juj0c7938g= +github.com/denisenkom/go-mssqldb v0.0.0-20180824013952-8fac8b954edb/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc= github.com/docker/distribution v2.6.2+incompatible h1:4FI6af79dfCS/CYb+RRtkSHw3q1L/bnDjG1PcPZtQhM= github.com/docker/distribution v2.6.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v1.13.1 h1:5VBhsO6ckUxB0A8CE5LlUJdXzik9cbEbBTQ/ggeml7M= @@ -22,10 +22,10 @@ github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= -github.com/getsentry/raven-go v0.0.0-20180801005657-7535a8fa2ace h1:M5ZUuRO+XFqhTa9PlaqyWgfzMNWKSraCWm7z4PzM1GA= -github.com/getsentry/raven-go v0.0.0-20180801005657-7535a8fa2ace/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= -github.com/gin-contrib/multitemplate v0.0.0-20180607024123-41d1d62d1df3 h1:nKrMd5DcMWMxZbGzSEscZ7zsnA0vLf46rGKV1R7c4Kc= -github.com/gin-contrib/multitemplate v0.0.0-20180607024123-41d1d62d1df3/go.mod h1:62qM8p4crGvNKE413gTzn4eMFin1VOJfMDWMRzHdvqM= +github.com/getsentry/raven-go v0.0.0-20180827214142-a9457d81ec91 h1:UEqh4D2oCkhWyneNnG6eCqbpHrmQ9nLLgsIpuPwRxDw= +github.com/getsentry/raven-go v0.0.0-20180827214142-a9457d81ec91/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= +github.com/gin-contrib/multitemplate v0.0.0-20180827023943-5799bbbb6dce h1:KqeVCdb+M2iwyF6GzdYxTazfE1cE+133RXuGaZ5Sc1E= +github.com/gin-contrib/multitemplate v0.0.0-20180827023943-5799bbbb6dce/go.mod h1:62qM8p4crGvNKE413gTzn4eMFin1VOJfMDWMRzHdvqM= github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 h1:AzN37oI0cOS+cougNAV9szl6CVoj2RYwzS3DpUQNtlY= github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-gonic/gin v1.3.0 h1:kCmZyPklC0gVdL728E6Aj20uYBJV93nj/TkwBTKhFbs= @@ -46,8 +46,8 @@ github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 h1:zLTLjkaOFEFIOxY5BWLFLwh+cL8vOBW4XJ2aqLE/Tf0= github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/gopherjs/gopherjs v0.0.0-20180820052304-89baedc74dd7 h1:WF7x3tAe0mEb4wf/yhSThHwZYQIjVmEGSbAH9hzOeZQ= -github.com/gopherjs/gopherjs v0.0.0-20180820052304-89baedc74dd7/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c h1:16eHWuMGvCjSfgRJKqIzapE78onvvTbdi1rMkU00lZw= +github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/h2non/gock v1.0.9 h1:17gCehSo8ZOgEsFKpQgqHiR7VLyjxdAG3lkhVvO9QZU= github.com/h2non/gock v1.0.9/go.mod h1:CZMcB0Lg5IWnr9bF79pPMg9WeV6WumxQiUJ1UvdO1iE= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= @@ -62,26 +62,25 @@ github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 h1:12VvqtR6Ao github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/json-iterator/go v0.0.0-20180806060727-1624edc4454b h1:X61dhFTE1Au92SvyF8HyAwdjWqiSdfBgFR7wTxC0+uU= -github.com/json-iterator/go v0.0.0-20180806060727-1624edc4454b/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.2/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180718012357-94122c33edd3 h1:YFBuDro+e1UCqlJpDWGucQaO/UNhBX1GlS8Du0GNfPw= -github.com/modern-go/reflect2 v0.0.0-20180718012357-94122c33edd3/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/nicksnyder/go-i18n/v2 v2.0.0-beta.5 h1:/TjjTS4kg7vC+05gD0LE4+97f/+PRFICnK/7wJPk7kE= @@ -92,31 +91,30 @@ github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/retailcrm/api-client-go v1.0.4 h1:pYlkdQhesc8MN/huU4qp9XpLLRxfr0SIICf2RmEVnoA= -github.com/retailcrm/api-client-go v1.0.4/go.mod h1:QRoPE2SM6ST7i2g0yEdqm7Iw98y7cYuq3q14Ot+6N8c= -github.com/retailcrm/mg-transport-api-client-go v1.1.2 h1:PL/IjYhsiD3LZ08YXTZGbwLmnOL1ulOUr8wGWE28g9A= -github.com/retailcrm/mg-transport-api-client-go v1.1.2/go.mod h1:AWV6BueE28/6SCoyfKURTo4lF0oXYoOKmHTzehd5vAI= +github.com/retailcrm/api-client-go v1.0.6 h1:4Q3e4ve8GOOHIQdq3/wTGqgWuWa1cKMKqmgrTv4FoDU= +github.com/retailcrm/api-client-go v1.0.6/go.mod h1:QRoPE2SM6ST7i2g0yEdqm7Iw98y7cYuq3q14Ot+6N8c= +github.com/retailcrm/mg-transport-api-client-go v1.1.4 h1:eBSZukT0tk/Alf4CGQz6vDe8toD0QA8JyWx65fjVRCE= +github.com/retailcrm/mg-transport-api-client-go v1.1.4/go.mod h1:AWV6BueE28/6SCoyfKURTo4lF0oXYoOKmHTzehd5vAI= github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf h1:6V1qxN6Usn4jy8unvggSJz/NC790tefw8Zdy6OZS5co= github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a h1:JSvGDIbmil4Ui/dDdFBExb7/cmkNjyX5F97oglmvCDo= github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= -github.com/stevvooe/resumable v0.0.0-20170302213456-2aaf90b2ceea h1:KR90QmB10LunzqE3lvSRq0epy66wkQi2bDmkJdkkxi8= -github.com/stevvooe/resumable v0.0.0-20170302213456-2aaf90b2ceea/go.mod h1:1pdIZTAHUz+HDKDVZ++5xg/duPlhKAIzw9qy42CWYp4= +github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 h1:4bT0pPowCpQImewr+BjzfUKcuFW+KVyB8d1OF3b6oTI= +github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50/go.mod h1:1pdIZTAHUz+HDKDVZ++5xg/duPlhKAIzw9qy42CWYp4= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= github.com/ugorji/go v1.1.1 h1:gmervu+jDMvXTbcHQ0pd2wee85nEoE0BsVyEuzkfK8w= github.com/ugorji/go v1.1.1/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= -golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac h1:7d7lG9fHOLdL6jZPtnV4LpI41SbohIJ1Atq7U991dMg= -golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/net v0.0.0-20180821023952-922f4815f713 h1:rMJUcaDGbG+X967I4zGKCq5laYqcGKJmpB+3jhpOhPw= -golang.org/x/net v0.0.0-20180821023952-922f4815f713/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/crypto v0.0.0-20180830192347-182538f80094 h1:rVTAlhYa4+lCfNxmAIEOGQRoD23UqP72M3+rSWVGDTg= +golang.org/x/crypto v0.0.0-20180830192347-182538f80094/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d h1:g9qWBGx4puODJTMVyoPrpoxPFgVGd+z1DZwjfRu4d0I= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180821140842-3b58ed4ad339 h1:0w2EXzxbB03VAzqwe3csbadu4CPhMRtxCz/rjw9gkic= -golang.org/x/sys v0.0.0-20180821140842-3b58ed4ad339/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180831094639-fa5fdf94c789 h1:T8D7l6WB3tLu+VpKvw06ieD/OhBi1XpJmG1U/FtttZg= +golang.org/x/sys v0.0.0-20180831094639-fa5fdf94c789/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.0.0-20171214130843-f21a4dfb5e38/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/src/locale.go b/src/locale.go index 40e7fe8..88301bb 100644 --- a/src/locale.go +++ b/src/locale.go @@ -1,6 +1,7 @@ package main import ( + "html/template" "io/ioutil" "github.com/nicksnyder/go-i18n/v2/i18n" @@ -40,8 +41,8 @@ func getLocalizedMessage(messageID string) string { return localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: messageID}) } -func getLocale() map[string]string { - return map[string]string{ +func getLocale() map[string]interface{} { + return map[string]interface{}{ "ButtonSave": getLocalizedMessage("button_save"), "ApiKey": getLocalizedMessage("api_key"), "TabSettings": getLocalizedMessage("tab_settings"), @@ -51,5 +52,8 @@ func getLocale() map[string]string { "AddBot": getLocalizedMessage("add_bot"), "TableDelete": getLocalizedMessage("table_delete"), "Title": getLocalizedMessage("title"), + "InfoBot": template.HTML(getLocalizedMessage("info_bot")), + "CRMLink": template.HTML(getLocalizedMessage("crm_link")), + "DocLink": template.HTML(getLocalizedMessage("doc_link")), } } diff --git a/src/repository.go b/src/repository.go index 1c62eed..522f280 100644 --- a/src/repository.go +++ b/src/repository.go @@ -29,6 +29,10 @@ func (c *Connection) createConnection() error { } func (c *Connection) saveConnection() error { + return orm.DB.Save(c).Error +} + +func (c *Connection) saveConnectionByClientID() error { return orm.DB.Model(c).Where("client_id = ?", c.ClientID).Update(c).Error } diff --git a/src/routing.go b/src/routing.go index 379ee85..1ae5e31 100644 --- a/src/routing.go +++ b/src/routing.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "fmt" "net/http" "strconv" @@ -15,10 +16,12 @@ import ( func connectHandler(c *gin.Context) { res := struct { Conn Connection - Locale map[string]string + Locale map[string]interface{} + Year int }{ c.MustGet("account").(Connection), getLocale(), + time.Now().Year(), } c.HTML(http.StatusOK, "home", &res) @@ -133,11 +136,13 @@ func settingsHandler(c *gin.Context) { res := struct { Conn *Connection Bots Bots - Locale map[string]string + Locale map[string]interface{} + Year int }{ p, bots, getLocale(), + time.Now().Year(), } c.HTML(http.StatusOK, "form", &res) @@ -155,7 +160,7 @@ func saveHandler(c *gin.Context) { return } - err = conn.saveConnection() + err = conn.saveConnectionByClientID() if err != nil { c.Error(err) return @@ -196,8 +201,8 @@ func createHandler(c *gin.Context) { return } - conn.MGURL = data.Info["baseUrl"] - conn.MGToken = data.Info["token"] + conn.MGURL = data.Info.MgTransportInfo.EndpointUrl + conn.MGToken = data.Info.MgTransportInfo.Token conn.Active = true err = conn.createConnection() @@ -216,14 +221,13 @@ func createHandler(c *gin.Context) { } func activityHandler(c *gin.Context) { - var rec v5.ActivityCallback + var ( + activity v5.Activity + systemUrl = c.PostForm("systemUrl") + clientId = c.PostForm("clientId") + ) - if err := c.ShouldBindJSON(&rec); err != nil { - c.Error(err) - return - } - - conn := getConnection(rec.ClientId) + conn := getConnection(clientId) if conn.ID == 0 { c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{ @@ -234,9 +238,24 @@ func activityHandler(c *gin.Context) { return } - conn.Active = rec.Activity.Active && !rec.Activity.Freeze + err := json.Unmarshal([]byte(c.PostForm("activity")), &activity) + if err != nil { + c.AbortWithStatusJSON(http.StatusBadRequest, + gin.H{ + "success": false, + "error": "Wrong data", + }, + ) + return + } - if err := conn.setConnectionActivity(); err != nil { + conn.Active = activity.Active && !activity.Freeze + + if systemUrl != "" { + conn.APIURL = systemUrl + } + + if err := conn.saveConnection(); err != nil { c.Error(err) return } diff --git a/src/routing_test.go b/src/routing_test.go index f6483dc..af770ad 100644 --- a/src/routing_test.go +++ b/src/routing_test.go @@ -187,14 +187,17 @@ func TestRouting_saveHandler(t *testing.T) { } func TestRouting_activityHandler(t *testing.T) { - req, err := http.NewRequest("POST", "/actions/activity", - strings.NewReader( - `{"clientId": "123123","activity": {"active": true}}`, - )) + data := url.Values{} + data.Set("clientId", "123123") + data.Set("activity", `{"active": true, "freeze": false}`) + + req, err := http.NewRequest("POST", "/actions/activity", strings.NewReader(data.Encode())) if err != nil { t.Fatal(err) } + req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + rr := httptest.NewRecorder() router.ServeHTTP(rr, req) diff --git a/static/script.js b/static/script.js index 2ebef7c..4acb1ea 100644 --- a/static/script.js +++ b/static/script.js @@ -44,19 +44,41 @@ $("#add-bot").on("submit", function(e) { }); $(document).on("click", ".delete-bot", function(e) { - let but = $(this); - send("/delete-bot/", - { - token: but.attr("data-token"), - connectionId: parseInt($('input[name=connectionId]').val()), - }, - function () { - but.parents("tr").remove(); - if ($("#bots tbody tr").length === 0) { - $("#bots").addClass("hide"); - } + e.preventDefault(); + var but = $(this); + var confirmText = JSON.parse(sessionStorage.getItem("confirmText")); + + $.confirm({ + title: false, + content: confirmText["text"], + useBootstrap: false, + boxWidth: '30%', + type: 'blue', + backgroundDismiss: false, + backgroundDismissAnimation: 'shake', + buttons: { + confirm: { + text: confirmText["confirm"], + action: function () { + send("/delete-bot/", + { + token: but.attr("data-token"), + connectionId: parseInt($('input[name=connectionId]').val()), + }, + function () { + but.parents("tr").remove(); + if ($("#bots tbody tr").length === 0) { + $("#bots").addClass("hide"); + } + } + ) + }, + }, + cancel: { + text: confirmText["cancel"], + }, } - ) + }); }); function send(url, data, callback) { @@ -103,6 +125,29 @@ $( document ).ready(function() { $("#bots").addClass("hide"); } + if (!sessionStorage.getItem("confirmText")) { + let confirmText = {}; + + switch (navigator.language.split('-')[0]) { + case "ru": + confirmText["text"] = "Вы уверены, что хотите удалить?"; + confirmText["confirm"] = "да"; + confirmText["cancel"] = "нет"; + break; + case "es": + confirmText["text"] = "¿Estás seguro que quieres borrar?"; + confirmText["confirm"] = "sí"; + confirmText["cancel"] = "no"; + break; + default: + confirmText["text"] = "Are you sure you want to delete?"; + confirmText["confirm"] = "yes"; + confirmText["cancel"] = "no"; + } + + sessionStorage.setItem("confirmText", JSON.stringify(confirmText)); + } + let createdMsg = sessionStorage.getItem("createdMsg"); if (createdMsg) { setTimeout(function() { diff --git a/static/style.css b/static/style.css index ce9aa32..51b9d62 100644 --- a/static/style.css +++ b/static/style.css @@ -1,3 +1,13 @@ +body { + display: flex; + min-height: 100vh; + flex-direction: column; +} + +main { + flex: 1 0 auto; +} + .indent-top { margin-top: 2%; } @@ -11,7 +21,9 @@ margin: 0 auto 23px; } -.tab-el-center{ +.docs, +.tab-el-center, +.footer-copyright{ width: 67%; margin: 0 auto; } @@ -102,3 +114,17 @@ background-color: #039be5; will-change: left, right; } + +.docs p { + text-align: center; + color: #9e9e9e; +} + +.footer-copyright { + border-top: 1px solid #9e9e9e; + margin-top: 10px; +} + +.footer-copyright p { + color: #9e9e9e; +} diff --git a/templates/form.html b/templates/form.html index 455882a..7a96a4e 100644 --- a/templates/form.html +++ b/templates/form.html @@ -32,6 +32,9 @@
{{.Locale.InfoBot}}
+