Files
remark42/backend/vendor/github.com/slack-go/slack/team.go
T
Dmitry VerkhoturovandUmputun 80c12a3f10 chore(deps): update Go modules
Bump Go dependencies in both backend/ and backend/_example/memory_store.

Notable updates:
- github.com/go-pkgz/lgr v0.12.1 -> v0.12.3
- github.com/klauspost/compress v1.18.2 -> v1.18.5
- github.com/PuerkitoBio/goquery v1.11.0 -> v1.12.0
- github.com/montanaflynn/stats v0.7.1 -> v0.9.0
- github.com/redis/go-redis/v9 v9.17.2 -> v9.18.0
- github.com/slack-go/slack v0.17.3 -> v0.21.1
- go.mongodb.org/mongo-driver v1.17.6 -> v1.17.9
- golang.org/x/crypto v0.48.0 -> v0.50.0
- golang.org/x/net v0.49.0 -> v0.53.0
- golang.org/x/image v0.36.0 -> v0.39.0
- golang.org/x/sys v0.41.0 -> v0.43.0
- golang.org/x/{oauth2,sync,text} minor bumps

Key markdown/sanitisation libs (bluemonday v1.0.27,
alecthomas/chroma/v2 v2.23.1, russross/blackfriday/v2 v2.1.0,
Depado/bfchroma/v2 v2.0.0) are already at the latest available
versions and were not bumped.

Verified the Chroma span-class allowlist regex in
backend/app/store/comment.go:128-131 is still fully in sync with
chroma/v2 types.go StandardTypes map (86 classes, byte-equal after
sorting). The inline comment references commit c263f6f which is
stale (Chroma is at v2 now), but the class list content is current.

Ran `go mod tidy` + `go mod vendor` + full race test suite on both
modules. All green. Added a reminder in CLAUDE.md that updating
backend/ Go modules also requires `go mod tidy` in
backend/_example/memory_store since the example module uses a
local replace directive and inherits indirect deps from the main
module.
2026-04-12 11:52:57 -05:00

247 lines
7.3 KiB
Go

package slack
import (
"context"
"net/url"
"strconv"
)
type TeamResponse struct {
Team TeamInfo `json:"team"`
SlackResponse
}
type TeamInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Domain string `json:"domain"`
EmailDomain string `json:"email_domain"`
Icon map[string]interface{} `json:"icon"`
}
type TeamProfileResponse struct {
Profile TeamProfile `json:"profile"`
SlackResponse
}
type TeamProfile struct {
Fields []TeamProfileField `json:"fields"`
}
type TeamProfileField struct {
ID string `json:"id"`
Ordering int `json:"ordering"`
Label string `json:"label"`
Hint string `json:"hint"`
Type string `json:"type"`
PossibleValues []string `json:"possible_values"`
IsHidden bool `json:"is_hidden"`
Options map[string]bool `json:"options"`
}
type LoginResponse struct {
Logins []Login `json:"logins"`
SlackResponse
ResponseMetadata `json:"response_metadata"`
}
type Login struct {
UserID string `json:"user_id"`
Username string `json:"username"`
DateFirst int `json:"date_first"`
DateLast int `json:"date_last"`
Count int `json:"count"`
IP string `json:"ip"`
UserAgent string `json:"user_agent"`
ISP string `json:"isp"`
Country string `json:"country"`
Region string `json:"region"`
}
type BillableInfoResponse struct {
BillableInfo map[string]BillingActive `json:"billable_info"`
SlackResponse
}
type BillingActive struct {
BillingActive bool `json:"billing_active"`
}
// AccessLogParameters contains all the parameters necessary (including the optional ones) for a GetAccessLogs() request
type AccessLogParameters struct {
TeamID string
Cursor string
Limit int
Before int
}
// NewAccessLogParameters provides an instance of AccessLogParameters with all the sane default values set
func NewAccessLogParameters() AccessLogParameters {
return AccessLogParameters{}
}
func (api *Client) teamRequest(ctx context.Context, path string, values url.Values) (*TeamResponse, error) {
response := &TeamResponse{}
err := api.postMethod(ctx, path, values, response)
if err != nil {
return nil, err
}
return response, response.Err()
}
func (api *Client) billableInfoRequest(ctx context.Context, path string, values url.Values) (map[string]BillingActive, error) {
response := &BillableInfoResponse{}
err := api.postMethod(ctx, path, values, response)
if err != nil {
return nil, err
}
return response.BillableInfo, response.Err()
}
func (api *Client) accessLogsRequest(ctx context.Context, path string, values url.Values) (*LoginResponse, error) {
response := &LoginResponse{}
err := api.postMethod(ctx, path, values, response)
if err != nil {
return nil, err
}
return response, response.Err()
}
func (api *Client) teamProfileRequest(ctx context.Context, path string, values url.Values) (*TeamProfileResponse, error) {
response := &TeamProfileResponse{}
err := api.postMethod(ctx, path, values, response)
if err != nil {
return nil, err
}
return response, response.Err()
}
// GetTeamInfo gets the Team Information of the user.
// For more information see the GetTeamInfoContext documentation.
func (api *Client) GetTeamInfo() (*TeamInfo, error) {
return api.GetTeamInfoContext(context.Background())
}
// GetOtherTeamInfoContext gets Team information for any team with a custom context.
// Slack API docs: https://api.slack.com/methods/team.info
func (api *Client) GetOtherTeamInfoContext(ctx context.Context, team string) (*TeamInfo, error) {
if team == "" {
return api.GetTeamInfoContext(ctx)
}
values := url.Values{
"token": {api.token},
}
values.Add("team", team)
response, err := api.teamRequest(ctx, "team.info", values)
if err != nil {
return nil, err
}
return &response.Team, nil
}
// GetOtherTeamInfo gets Team information for any team.
// For more information see the GetOtherTeamInfoContext documentation.
func (api *Client) GetOtherTeamInfo(team string) (*TeamInfo, error) {
return api.GetOtherTeamInfoContext(context.Background(), team)
}
// GetTeamInfoContext gets the Team Information of the user with a custom context.
// Slack API docs: https://api.slack.com/methods/team.info
func (api *Client) GetTeamInfoContext(ctx context.Context) (*TeamInfo, error) {
values := url.Values{
"token": {api.token},
}
response, err := api.teamRequest(ctx, "team.info", values)
if err != nil {
return nil, err
}
return &response.Team, nil
}
// GetTeamProfile gets the Team Profile settings of the user.
// For more information see the GetTeamProfileContext documentation.
func (api *Client) GetTeamProfile(teamID ...string) (*TeamProfile, error) {
return api.GetTeamProfileContext(context.Background(), teamID...)
}
// GetTeamProfileContext gets the Team Profile settings of the user with a custom context.
// Slack API docs: https://api.slack.com/methods/team.profile.get
func (api *Client) GetTeamProfileContext(ctx context.Context, teamID ...string) (*TeamProfile, error) {
values := url.Values{
"token": {api.token},
}
if len(teamID) > 0 {
values["team_id"] = teamID
}
response, err := api.teamProfileRequest(ctx, "team.profile.get", values)
if err != nil {
return nil, err
}
return &response.Profile, nil
}
// GetAccessLogs retrieves a page of logins according to the parameters given.
// For more information see the GetAccessLogsContext documentation.
func (api *Client) GetAccessLogs(params AccessLogParameters) ([]Login, string, error) {
return api.GetAccessLogsContext(context.Background(), params)
}
// GetAccessLogsContext retrieves a page of logins according to the parameters given with a custom context.
// Slack API docs: https://api.slack.com/methods/team.accessLogs
func (api *Client) GetAccessLogsContext(ctx context.Context, params AccessLogParameters) ([]Login, string, error) {
values := url.Values{
"token": {api.token},
}
if params.TeamID != "" {
values.Add("team_id", params.TeamID)
}
if params.Cursor != "" {
values.Add("cursor", params.Cursor)
}
if params.Limit != 0 {
values.Add("limit", strconv.Itoa(params.Limit))
}
if params.Before != 0 {
values.Add("before", strconv.Itoa(params.Before))
}
response, err := api.accessLogsRequest(ctx, "team.accessLogs", values)
if err != nil {
return nil, "", err
}
return response.Logins, response.ResponseMetadata.Cursor, nil
}
type GetBillableInfoParams struct {
User string
TeamID string
}
// GetBillableInfo gets the billable users information of the team.
// For more information see the GetBillableInfoContext documentation.
func (api *Client) GetBillableInfo(params GetBillableInfoParams) (map[string]BillingActive, error) {
return api.GetBillableInfoContext(context.Background(), params)
}
// GetBillableInfoContext gets the billable users information of the team with a custom context.
// Slack API docs: https://api.slack.com/methods/team.billableInfo
func (api *Client) GetBillableInfoContext(ctx context.Context, params GetBillableInfoParams) (map[string]BillingActive, error) {
values := url.Values{
"token": {api.token},
}
if params.TeamID != "" {
values.Add("team_id", params.TeamID)
}
if params.User != "" {
values.Add("user", params.User)
}
return api.billableInfoRequest(ctx, "team.billableInfo", values)
}