Files
Dmitry Verkhoturov 07c7926453 Update backend dependencies to latest
Update all Go modules in backend/ and backend/_example/memory_store/ to
their latest versions (chroma 2.27, go-redis 9.21, bbolt 1.5, slack 0.27,
golang.org/x/* and others); re-tidy and re-vendor, keep the example module
in sync.

Hold github.com/go-chi/chi/v5 at v5.2.5: v5.3.0 deprecates
middleware.RealIP (IP-spoofing advisories). Switching off RealIP changes
how the client IP is derived for rate limiting and votes, which is a
security decision better made on its own rather than inside a dependency
bump.

go test -race, go vet, golangci-lint and govulncheck all clean on both
modules.
2026-06-30 18:35:31 +01:00

46 lines
1.5 KiB
Go

package slack
import (
"context"
"net/url"
)
// SocketModeConnection contains various details about the SocketMode connection.
// It is returned by an "apps.connections.open" API call.
type SocketModeConnection struct {
URL string `json:"url,omitempty"`
Data map[string]any `json:"-"`
}
type openResponseFull struct {
SlackResponse
SocketModeConnection
}
// StartSocketModeContext calls the "apps.connections.open" endpoint and returns the provided URL and the full Info block with a custom context.
//
// To have a fully managed Socket Mode connection, use `socketmode.New()`, and call `Run()` on it.
func (api *Client) StartSocketModeContext(ctx context.Context) (info *SocketModeConnection, websocketURL string, err error) {
response := &openResponseFull{}
err = api.postJSONMethod(ctx, "apps.connections.open", api.appLevelToken, nil, response)
if err != nil {
return nil, "", err
}
if response.Err() == nil {
api.Debugln("Using URL:", response.SocketModeConnection.URL)
}
// According to the API documentation at https://api.slack.com/apis/socket-mode, we
// can add a query parameter `debug_reconnects=true` to the URL to make the connection
// time significantly shorter (360 seconds).
if api.debug {
u, _ := url.Parse(response.SocketModeConnection.URL)
q := u.Query()
q.Set("debug_reconnects", "true")
u.RawQuery = q.Encode()
response.SocketModeConnection.URL = u.String()
}
return &response.SocketModeConnection, response.SocketModeConnection.URL, response.Err()
}