Merge pull request #3 from iyzoer/bug-fix

Fixes go.sum, remove slash on activate/deactivate module
This commit is contained in:
Alex Lushpai 2019-02-19 12:48:01 +03:00 committed by GitHub
commit 0fd85ee8d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 6 deletions

View file

@ -1,4 +1,4 @@
FROM golang:1.11.5-stretch
FROM golang:1.11-stretch
WORKDIR /
ADD ./bin/bot /

View file

@ -11,7 +11,7 @@ services:
- ${POSTGRES_ADDRESS:-127.0.0.1:5434}:${POSTGRES_PORT:-5432}
mg_bot_test:
image: golang:1.11.5-stretch
image: golang:1.11-stretch
working_dir: /mg-bot
user: ${UID:-1000}:${GID:-1000}
environment:

2
go.sum
View file

@ -12,7 +12,7 @@ github.com/denisenkom/go-mssqldb v0.0.0-20180901172138-1eb28afdf9b6 h1:BZGp1dbKF
github.com/denisenkom/go-mssqldb v0.0.0-20180901172138-1eb28afdf9b6/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=
github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=
github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=

View file

@ -1,5 +1,11 @@
package main
import (
"regexp"
)
var rx = regexp.MustCompile(`/+$`)
func getConnection(uid string) *Connection {
var connection Connection
orm.DB.First(&connection, "client_id = ?", uid)
@ -32,3 +38,7 @@ func (c *Connection) createConnection() error {
func (c *Connection) saveConnection() error {
return orm.DB.Model(c).Where("client_id = ?", c.ClientID).Update(c).Error
}
func (c *Connection) NormalizeApiUrl() {
c.APIURL = rx.ReplaceAllString(c.APIURL, ``)
}

View file

@ -196,6 +196,7 @@ func activityHandler(c *gin.Context) {
if systemUrl != "" {
conn.APIURL = systemUrl
}
conn.NormalizeApiUrl()
if err := conn.setConnectionActivity(); err != nil {
c.Error(err)

View file

@ -4,7 +4,6 @@ import (
"net/http"
"os"
"os/signal"
"regexp"
"syscall"
"github.com/getsentry/raven-go"
@ -24,7 +23,6 @@ func init() {
var (
sentry *raven.Client
rx = regexp.MustCompile(`/+$`)
wm = NewWorkersManager()
)
@ -129,7 +127,7 @@ func checkConnectionForRequest() gin.HandlerFunc {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": getLocalizedMessage("incorrect_url_key")})
return
}
conn.APIURL = rx.ReplaceAllString(conn.APIURL, ``)
conn.NormalizeApiUrl()
c.Set("connection", conn)
}