Debian Codegraph @

socket_mode.go

raw symbols SCIP
1 package slack
2
3 import (
4 "context"
5 )
6
7 // SocketModeConnection contains various details about the SocketMode connection.
8 // It is returned by an "apps.connections.open" API call.
9 type SocketModeConnection struct {
10 URL string `json:"url,omitempty"`
11 Data map[string]interface{} `json:"-"`
12 }
13
14 type openResponseFull struct {
15 SlackResponse
16 SocketModeConnection
17 }
18
19 // StartSocketModeContext calls the "apps.connections.open" endpoint and returns the provided URL and the full Info block with a custom context.
20 //
21 // To have a fully managed Socket Mode connection, use `socketmode.New()`, and call `Run()` on it.
22 func (api *Client) StartSocketModeContext(ctx context.Context) (info *SocketModeConnection, websocketURL string, err error) {
23 response := &openResponseFull{}
24 err = postJSON(ctx, api.httpclient, api.endpoint+"apps.connections.open", api.appLevelToken, nil, response, api)
25 if err != nil {
26 return nil, "", err
27 }
28
29 if response.Err() == nil {
30 api.Debugln("Using URL:", response.SocketModeConnection.URL)
31 }
32
33 return &response.SocketModeConnection, response.SocketModeConnection.URL, response.Err()
34 }