Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions pkg/connector/client/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ func MapSlackErrorToGRPCCode(slackError string) codes.Code {
return codes.NotFound
}

// no_such_subteam is a transient error - map to Unavailable to trigger SDK retry (CXH-434).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is no_such_subteam a transient error? I doesn't sound like it would be? I asked this in the other repo too.

if containsAny(err, SlackErrNoSuchSubteam) {
return codes.Unavailable
}

if containsAny(err, "user_already_team_member") {
return codes.AlreadyExists
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/connector/client/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ const (
// Slack API error string constants.
SlackErrUserAlreadyTeamMember = "user_already_team_member"
SlackErrUserAlreadyDeleted = "user_already_deleted"
ScimVersionV2 = "v2"
ScimVersionV1 = "v1"
// SlackErrNoSuchSubteam is returned when a user group is temporarily unreachable (CXH-434).
SlackErrNoSuchSubteam = "no_such_subteam"
ScimVersionV2 = "v2"
ScimVersionV1 = "v1"
)

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