add channel configuration update
This commit is contained in:
parent
8dff7e5f41
commit
f4704f6652
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.1.0 h1:APPO6ccJAeMV7Jz7BhrtDKSOm2r1j5Ft6fuEXNP2ij4=
|
github.com/retailcrm/api-client-go v1.1.0 h1:APPO6ccJAeMV7Jz7BhrtDKSOm2r1j5Ft6fuEXNP2ij4=
|
||||||
github.com/retailcrm/api-client-go v1.1.0/go.mod h1:QRoPE2SM6ST7i2g0yEdqm7Iw98y7cYuq3q14Ot+6N8c=
|
github.com/retailcrm/api-client-go v1.1.0/go.mod h1:QRoPE2SM6ST7i2g0yEdqm7Iw98y7cYuq3q14Ot+6N8c=
|
||||||
github.com/retailcrm/mg-transport-api-client-go v1.1.17 h1:8L0meFJFZwr3TyiF/xypI+g0xRXIGkWhyQ6qiCfojqw=
|
|
||||||
github.com/retailcrm/mg-transport-api-client-go v1.1.17/go.mod h1:AWV6BueE28/6SCoyfKURTo4lF0oXYoOKmHTzehd5vAI=
|
|
||||||
github.com/retailcrm/mg-transport-api-client-go v1.1.18 h1:V59Ai79N1jrS1kAnQggNoRYsoAdr2RUV7Hf0xbw9r9Q=
|
github.com/retailcrm/mg-transport-api-client-go v1.1.18 h1:V59Ai79N1jrS1kAnQggNoRYsoAdr2RUV7Hf0xbw9r9Q=
|
||||||
github.com/retailcrm/mg-transport-api-client-go v1.1.18/go.mod h1:AWV6BueE28/6SCoyfKURTo4lF0oXYoOKmHTzehd5vAI=
|
github.com/retailcrm/mg-transport-api-client-go v1.1.18/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=
|
||||||
|
@ -75,6 +75,14 @@ func addBotHandler(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
b.Channel = data.ChannelID
|
b.Channel = data.ChannelID
|
||||||
|
b.Lang = "en"
|
||||||
|
|
||||||
|
hashSettings, err := getChannelSettingsHash()
|
||||||
|
if err != nil {
|
||||||
|
logger.Errorf("addBotHandler hashSettings apiURl: %s, err: %s", conn.APIURL, err.Error())
|
||||||
|
} else {
|
||||||
|
b.ChannelSettingsHash = hashSettings
|
||||||
|
}
|
||||||
|
|
||||||
err = conn.createBot(b)
|
err = conn.createBot(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -253,6 +261,13 @@ func activityHandler(c *gin.Context) {
|
|||||||
conn.APIURL = systemUrl
|
conn.APIURL = systemUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hashSettings, err := getChannelSettingsHash()
|
||||||
|
if err != nil {
|
||||||
|
logger.Errorf("activityHandler hashSettings apiURl: %s, err: %s", conn.APIURL, err.Error())
|
||||||
|
} else {
|
||||||
|
updateBots(conn, hashSettings)
|
||||||
|
}
|
||||||
|
|
||||||
if err := conn.saveConnection(); err != nil {
|
if err := conn.saveConnection(); err != nil {
|
||||||
c.Error(err)
|
c.Error(err)
|
||||||
return
|
return
|
||||||
|
@ -13,12 +13,12 @@ import (
|
|||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/h2non/gock"
|
"github.com/h2non/gock"
|
||||||
"github.com/retailcrm/mg-transport-api-client-go/v1"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var router *gin.Engine
|
var router *gin.Engine
|
||||||
|
var ch = getChannelSettings()
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
os.Chdir("../")
|
os.Chdir("../")
|
||||||
@ -56,48 +56,9 @@ func TestRouting_connectHandler(t *testing.T) {
|
|||||||
func TestRouting_addBotHandler(t *testing.T) {
|
func TestRouting_addBotHandler(t *testing.T) {
|
||||||
defer gock.Off()
|
defer gock.Off()
|
||||||
|
|
||||||
ch := v1.Channel{
|
ch.Name = "@TestBot"
|
||||||
Type: "telegram",
|
|
||||||
Name: "@TestBot",
|
|
||||||
Settings: v1.ChannelSettings{
|
|
||||||
SpamAllowed: false,
|
|
||||||
Status: v1.Status{
|
|
||||||
Delivered: v1.ChannelFeatureSend,
|
|
||||||
Read: v1.ChannelFeatureNone,
|
|
||||||
},
|
|
||||||
Text: v1.ChannelSettingsText{
|
|
||||||
Creating: v1.ChannelFeatureBoth,
|
|
||||||
Editing: v1.ChannelFeatureBoth,
|
|
||||||
Quoting: v1.ChannelFeatureBoth,
|
|
||||||
Deleting: v1.ChannelFeatureReceive,
|
|
||||||
MaxCharsCount: MaxCharsCount,
|
|
||||||
},
|
|
||||||
Product: v1.Product{
|
|
||||||
Creating: v1.ChannelFeatureReceive,
|
|
||||||
Editing: v1.ChannelFeatureReceive,
|
|
||||||
},
|
|
||||||
Order: v1.Order{
|
|
||||||
Creating: v1.ChannelFeatureReceive,
|
|
||||||
Editing: v1.ChannelFeatureReceive,
|
|
||||||
},
|
|
||||||
File: v1.ChannelSettingsFilesBase{
|
|
||||||
Creating: v1.ChannelFeatureBoth,
|
|
||||||
Editing: v1.ChannelFeatureBoth,
|
|
||||||
Quoting: v1.ChannelFeatureBoth,
|
|
||||||
Deleting: v1.ChannelFeatureReceive,
|
|
||||||
Max: 1,
|
|
||||||
},
|
|
||||||
Image: v1.ChannelSettingsFilesBase{
|
|
||||||
Creating: v1.ChannelFeatureBoth,
|
|
||||||
Editing: v1.ChannelFeatureBoth,
|
|
||||||
Quoting: v1.ChannelFeatureBoth,
|
|
||||||
Deleting: v1.ChannelFeatureReceive,
|
|
||||||
Max: 10,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
outgoing, _ := json.Marshal(&ch)
|
outgoing, _ := json.Marshal(ch)
|
||||||
p := url.Values{"url": {"https://" + config.HTTPServer.Host + "/telegram/123123:Qwerty"}}
|
p := url.Values{"url": {"https://" + config.HTTPServer.Host + "/telegram/123123:Qwerty"}}
|
||||||
|
|
||||||
gock.New("https://api.telegram.org").
|
gock.New("https://api.telegram.org").
|
||||||
|
Loading…
Reference in New Issue
Block a user