diff --git a/go.sum b/go.sum index bc464c0..ae3bcb5 100644 --- a/go.sum +++ b/go.sum @@ -95,8 +95,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 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.9 h1:ogh5ThoqZJM5v4ZY6CqctUj01pVVHfBLXkrmX+BFjHE= -github.com/retailcrm/mg-transport-api-client-go v1.1.9/go.mod h1:AWV6BueE28/6SCoyfKURTo4lF0oXYoOKmHTzehd5vAI= github.com/retailcrm/mg-transport-api-client-go v1.1.10 h1:RR8S5NA6FPVrF6UVXaLwu/gJyKUg5aUObQ97S98M3Yc= github.com/retailcrm/mg-transport-api-client-go v1.1.10/go.mod h1:AWV6BueE28/6SCoyfKURTo4lF0oXYoOKmHTzehd5vAI= github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf h1:6V1qxN6Usn4jy8unvggSJz/NC790tefw8Zdy6OZS5co= diff --git a/src/routing.go b/src/routing.go index d48e4bb..6d5dca3 100644 --- a/src/routing.go +++ b/src/routing.go @@ -57,11 +57,16 @@ func addBotHandler(c *gin.Context) { return } - b.Name = bot.Self.FirstName + b.Name = bot.Self.UserName conn := getConnectionById(b.ConnectionID) client := v1.New(conn.MGURL, conn.MGToken) - data, status, err := client.ActivateTransportChannel(getChannelSettings()) + channelSettings := getChannelSettings() + if b.Name != "" { + channelSettings.Name = "@" + b.Name + } + + data, status, err := client.ActivateTransportChannel(channelSettings) if status != http.StatusCreated { c.AbortWithStatusJSON(BadRequest("error_activating_channel")) logger.Error(conn.APIURL, status, err.Error(), data) @@ -367,7 +372,12 @@ func updateBots(conn *Connection, hashSettings string) { continue } - data, status, err := client.UpdateTransportChannel(getChannelSettings(bot.Channel)) + channelSettings := getChannelSettings(bot.Channel) + if bot.Name != "" { + channelSettings.Name = "@" + bot.Name + } + + data, status, err := client.UpdateTransportChannel(channelSettings) if config.Debug { logger.Infof( "updateChannelsSettings apiURL: %s, ChannelID: %d, Data: %v, Status: %d, err: %v",