mirror of
https://github.com/retailcrm/mg-bot-api-client-go.git
synced 2024-11-21 20:36:05 +03:00
fix
This commit is contained in:
parent
de3eca3a55
commit
3e9078ee86
12
v1/client.go
12
v1/client.go
@ -925,7 +925,7 @@ func (c WsOption) apply(opts *wsParams) {
|
||||
}
|
||||
|
||||
// WsMeta let you receive url & headers to open web socket connection
|
||||
func (c *MgClient) WsMeta(events []string, opts ...WsParams) (string, http.Header, error) {
|
||||
func (c *MgClient) WsMeta(events []string, urlParams ...WsParams) (string, http.Header, error) {
|
||||
var url string
|
||||
|
||||
if len(events) < 1 {
|
||||
@ -935,12 +935,12 @@ func (c *MgClient) WsMeta(events []string, opts ...WsParams) (string, http.Heade
|
||||
|
||||
url = fmt.Sprintf("%s%s%s%s", strings.Replace(c.URL, "https", "wss", 1), prefix, "/ws?events=", strings.Join(events[:], ","))
|
||||
|
||||
var wsOpts wsParams
|
||||
for _, opt := range opts {
|
||||
opt.apply(&wsOpts)
|
||||
var params wsParams
|
||||
for _, opt := range urlParams {
|
||||
opt.apply(¶ms)
|
||||
}
|
||||
if len(wsOpts.options) > 0 {
|
||||
url = fmt.Sprintf("%s&options=%s", url, strings.Join(wsOpts.options, ","))
|
||||
if len(params.options) > 0 {
|
||||
url = fmt.Sprintf("%s&options=%s", url, strings.Join(params.options, ","))
|
||||
}
|
||||
|
||||
if url == "" {
|
||||
|
@ -849,9 +849,9 @@ func TestMgClient_CommandEditDelete(t *testing.T) {
|
||||
func TestMgClient_WsMeta_With_Options(t *testing.T) {
|
||||
c := client()
|
||||
events := []string{"user_updated", "user_join_chat"}
|
||||
options := []WsParams{WsOptionIncludeMassCommunication}
|
||||
params := []WsParams{WsOptionIncludeMassCommunication}
|
||||
|
||||
url, headers, err := c.WsMeta(events, options...)
|
||||
url, headers, err := c.WsMeta(events, params...)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user