add bot name in channel settings request
This commit is contained in:
parent
52d3bfada6
commit
eff4b1e0eb
2
go.sum
2
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/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 h1:4Q3e4ve8GOOHIQdq3/wTGqgWuWa1cKMKqmgrTv4FoDU=
|
||||||
github.com/retailcrm/api-client-go v1.0.6/go.mod h1:QRoPE2SM6ST7i2g0yEdqm7Iw98y7cYuq3q14Ot+6N8c=
|
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 h1:RR8S5NA6FPVrF6UVXaLwu/gJyKUg5aUObQ97S98M3Yc=
|
||||||
github.com/retailcrm/mg-transport-api-client-go v1.1.10/go.mod h1:AWV6BueE28/6SCoyfKURTo4lF0oXYoOKmHTzehd5vAI=
|
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=
|
github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf h1:6V1qxN6Usn4jy8unvggSJz/NC790tefw8Zdy6OZS5co=
|
||||||
|
@ -57,11 +57,16 @@ func addBotHandler(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Name = bot.Self.FirstName
|
b.Name = bot.Self.UserName
|
||||||
conn := getConnectionById(b.ConnectionID)
|
conn := getConnectionById(b.ConnectionID)
|
||||||
client := v1.New(conn.MGURL, conn.MGToken)
|
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 {
|
if status != http.StatusCreated {
|
||||||
c.AbortWithStatusJSON(BadRequest("error_activating_channel"))
|
c.AbortWithStatusJSON(BadRequest("error_activating_channel"))
|
||||||
logger.Error(conn.APIURL, status, err.Error(), data)
|
logger.Error(conn.APIURL, status, err.Error(), data)
|
||||||
@ -367,7 +372,12 @@ func updateBots(conn *Connection, hashSettings string) {
|
|||||||
continue
|
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 {
|
if config.Debug {
|
||||||
logger.Infof(
|
logger.Infof(
|
||||||
"updateChannelsSettings apiURL: %s, ChannelID: %d, Data: %v, Status: %d, err: %v",
|
"updateChannelsSettings apiURL: %s, ChannelID: %d, Data: %v, Status: %d, err: %v",
|
||||||
|
Loading…
Reference in New Issue
Block a user