Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
with:
connector: ./baton-slack
baton-entitlement: 'group:S0A1RHL4CP5:member'
baton-principal: 'U0847EPUZ0R'
baton-principal: 'U0A3NPX9Z5L'
baton-principal-type: 'user'
15 changes: 6 additions & 9 deletions pkg/connector/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
"github.com/conductorone/baton-sdk/pkg/actions"
"github.com/conductorone/baton-sdk/pkg/annotations"
"github.com/conductorone/baton-sdk/pkg/connectorbuilder"
"github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
"go.uber.org/zap"
"google.golang.org/protobuf/types/known/structpb"
Expand Down Expand Up @@ -96,26 +95,24 @@ var (
}
)

func (s *Slack) RegisterActionManager(ctx context.Context) (connectorbuilder.CustomActionManager, error) {
func (s *Slack) GlobalActions(ctx context.Context, registry actions.ActionRegistry) error {
l := ctxzap.Extract(ctx)

actionManager := actions.NewActionManager(ctx)

err := actionManager.RegisterAction(ctx, ActionDisableUser, disableUserSchema, s.handleDisableUser)
err := registry.Register(ctx, disableUserSchema, s.handleDisableUser)
if err != nil {
l.Error("failed to register disable_user action", zap.Error(err))
return nil, err
return err
}
l.Info("registered disable_user action")

err = actionManager.RegisterAction(ctx, ActionEnableUser, enableUserSchema, s.handleEnableUser)
err = registry.Register(ctx, enableUserSchema, s.handleEnableUser)
if err != nil {
l.Error("failed to register enable_user action", zap.Error(err))
return nil, err
return err
}

l.Info("registered enable_user action")
return actionManager, nil
return nil
}

// handleDisableUser deactivates a Slack user by setting active to false via SCIM API.
Expand Down
7 changes: 7 additions & 0 deletions pkg/connector/client/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ func MapSlackErrorToGRPCCode(slackError string) codes.Code {
return codes.NotFound
}

// no_such_subteam is returned when fetching user group members. We determined
// empirically that retrying on this error allows syncs to complete successfully,
// so we map it to Unavailable to trigger the SDK's automatic retry logic.
if containsAny(err, SlackErrNoSuchSubteam) {
return codes.Unavailable
}

if containsAny(err, "user_already_team_member") {
return codes.AlreadyExists
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/connector/client/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ const (
// Slack API error string constants.
SlackErrUserAlreadyTeamMember = "user_already_team_member"
SlackErrUserAlreadyDeleted = "user_already_deleted"
ScimVersionV2 = "v2"
ScimVersionV1 = "v1"
// SlackErrNoSuchSubteam is returned when fetching user group members. Retrying
// on this error was determined empirically to allow syncs to complete.
SlackErrNoSuchSubteam = "no_such_subteam"
ScimVersionV2 = "v2"
ScimVersionV1 = "v1"
)

var workspaceNameNamespace = sessions.WithPrefix("workspace_name")
Expand Down
Loading