Files
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

205 lines
6.3 KiB
Go

package slack
import (
"context"
"net/url"
"strconv"
"strings"
)
// AdminRolesAddAssignmentsParams contains arguments for AdminRolesAddAssignments method call.
type AdminRolesAddAssignmentsParams struct {
RoleID string
EntityIDs []string
UserIDs []string
}
// AdminRolesRejectedUser represents a user that could not be assigned a role.
type AdminRolesRejectedUser struct {
ID string `json:"id"`
Error string `json:"error"`
}
// AdminRolesRejectedEntity represents an entity that could not be assigned a role.
type AdminRolesRejectedEntity struct {
ID string `json:"id"`
Error string `json:"error"`
}
// AdminRolesAddAssignmentsResponse represents the response from admin.roles.addAssignments.
type AdminRolesAddAssignmentsResponse struct {
SlackResponse
RejectedUsers []AdminRolesRejectedUser `json:"rejected_users"`
RejectedEntities []AdminRolesRejectedEntity `json:"rejected_entities"`
}
// AdminRolesAddAssignments adds members to a specified role.
// For more information see the admin.roles.addAssignments docs:
// https://api.slack.com/methods/admin.roles.addAssignments
func (api *Client) AdminRolesAddAssignments(ctx context.Context, params AdminRolesAddAssignmentsParams) (*AdminRolesAddAssignmentsResponse, error) {
values := url.Values{
"token": {api.token},
"role_id": {params.RoleID},
}
if len(params.EntityIDs) > 0 {
values.Add("entity_ids", strings.Join(params.EntityIDs, ","))
}
if len(params.UserIDs) > 0 {
values.Add("user_ids", strings.Join(params.UserIDs, ","))
}
response := &AdminRolesAddAssignmentsResponse{}
err := api.postMethod(ctx, "admin.roles.addAssignments", values, response)
if err != nil {
return nil, err
}
return response, response.Err()
}
type adminRolesListAssignmentsParams struct {
roleIDs []string
entityIDs []string
limit int
cursor string
sortDirection string
}
// AdminRolesListAssignmentsOption is an option for AdminRolesListAssignments.
type AdminRolesListAssignmentsOption func(*adminRolesListAssignmentsParams)
// AdminRolesListAssignmentsOptionRoleIDs filters results to the specified role IDs.
func AdminRolesListAssignmentsOptionRoleIDs(roleIDs []string) AdminRolesListAssignmentsOption {
return func(params *adminRolesListAssignmentsParams) {
params.roleIDs = roleIDs
}
}
// AdminRolesListAssignmentsOptionEntityIDs filters results to the specified entity IDs.
func AdminRolesListAssignmentsOptionEntityIDs(entityIDs []string) AdminRolesListAssignmentsOption {
return func(params *adminRolesListAssignmentsParams) {
params.entityIDs = entityIDs
}
}
// AdminRolesListAssignmentsOptionLimit sets the maximum number of results to return.
func AdminRolesListAssignmentsOptionLimit(limit int) AdminRolesListAssignmentsOption {
return func(params *adminRolesListAssignmentsParams) {
params.limit = limit
}
}
// AdminRolesListAssignmentsOptionCursor sets the cursor for pagination.
func AdminRolesListAssignmentsOptionCursor(cursor string) AdminRolesListAssignmentsOption {
return func(params *adminRolesListAssignmentsParams) {
params.cursor = cursor
}
}
// AdminRolesListAssignmentsOptionSortDir sets the sort direction.
// Valid values: "asc", "desc".
func AdminRolesListAssignmentsOptionSortDir(sortDir string) AdminRolesListAssignmentsOption {
return func(params *adminRolesListAssignmentsParams) {
params.sortDirection = sortDir
}
}
// RoleAssignment represents a single role assignment.
type RoleAssignment struct {
RoleID string `json:"role_id"`
EntityID string `json:"entity_id,omitempty"`
UserID string `json:"user_id,omitempty"`
DateCreate int64 `json:"date_create,omitempty"`
}
// AdminRolesListAssignmentsResponse represents the response from admin.roles.listAssignments.
type AdminRolesListAssignmentsResponse struct {
SlackResponse
RoleAssignments []RoleAssignment `json:"role_assignments"`
ResponseMetadata ResponseMetadata `json:"response_metadata"`
}
// AdminRolesListAssignments lists assignments for roles.
// For more information see the admin.roles.listAssignments docs:
// https://api.slack.com/methods/admin.roles.listAssignments
func (api *Client) AdminRolesListAssignments(ctx context.Context, options ...AdminRolesListAssignmentsOption) (*AdminRolesListAssignmentsResponse, error) {
params := adminRolesListAssignmentsParams{}
for _, opt := range options {
opt(&params)
}
values := url.Values{
"token": {api.token},
}
if len(params.roleIDs) > 0 {
values.Add("role_ids", strings.Join(params.roleIDs, ","))
}
if len(params.entityIDs) > 0 {
values.Add("entity_ids", strings.Join(params.entityIDs, ","))
}
if params.limit > 0 {
values.Add("limit", strconv.Itoa(params.limit))
}
if params.cursor != "" {
values.Add("cursor", params.cursor)
}
if params.sortDirection != "" {
values.Add("sort_dir", params.sortDirection)
}
response := &AdminRolesListAssignmentsResponse{}
err := api.postMethod(ctx, "admin.roles.listAssignments", values, response)
if err != nil {
return nil, err
}
return response, response.Err()
}
// AdminRolesRemoveAssignmentsParams contains arguments for AdminRolesRemoveAssignments method call.
type AdminRolesRemoveAssignmentsParams struct {
RoleID string
EntityIDs []string
UserIDs []string
}
// AdminRolesRemoveAssignmentsResponse represents the response from admin.roles.removeAssignments.
type AdminRolesRemoveAssignmentsResponse struct {
SlackResponse
RejectedUsers []AdminRolesRejectedUser `json:"rejected_users"`
RejectedEntities []AdminRolesRejectedEntity `json:"rejected_entities"`
}
// AdminRolesRemoveAssignments removes members from a specified role.
// For more information see the admin.roles.removeAssignments docs:
// https://api.slack.com/methods/admin.roles.removeAssignments
func (api *Client) AdminRolesRemoveAssignments(ctx context.Context, params AdminRolesRemoveAssignmentsParams) (*AdminRolesRemoveAssignmentsResponse, error) {
values := url.Values{
"token": {api.token},
"role_id": {params.RoleID},
}
if len(params.EntityIDs) > 0 {
values.Add("entity_ids", strings.Join(params.EntityIDs, ","))
}
if len(params.UserIDs) > 0 {
values.Add("user_ids", strings.Join(params.UserIDs, ","))
}
response := &AdminRolesRemoveAssignmentsResponse{}
err := api.postMethod(ctx, "admin.roles.removeAssignments", values, response)
if err != nil {
return nil, err
}
return response, response.Err()
}