Documentation
¶
Overview ¶
Package channelaccess wires together the global account binding (channel identity <-> web user) and the per-bot Manage capability, resolving the effective Manage as "local override ?? inherited from bound web member".
Index ¶
- Variables
- type Binding
- type IssueLinkCodeRequest
- type LinkCode
- type ListBindingsResponse
- type ListManagersResponse
- type Manager
- type Service
- func (s *Service) ClearManagerOverride(ctx context.Context, botID, channelIdentityID string) error
- func (s *Service) ConsumeLinkCode(ctx context.Context, token, channelIdentityID string) (Binding, error)
- func (s *Service) HasManageGrant(ctx context.Context, botID, channelIdentityID string) (bool, error)
- func (s *Service) IssueLinkCode(ctx context.Context, userID, channelType string) (LinkCode, error)
- func (s *Service) ListManagers(ctx context.Context, botID string) ([]Manager, error)
- func (s *Service) ListUserBindings(ctx context.Context, userID string) ([]Binding, error)
- func (s *Service) SetManager(ctx context.Context, botID, channelIdentityID string, granted bool, ...) error
- func (s *Service) Unbind(ctx context.Context, userID, channelIdentityID string) error
- type SetManagerRequest
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Binding ¶
type Binding struct {
ID string `json:"id"`
UserID string `json:"user_id"`
ChannelIdentityID string `json:"channel_identity_id"`
ChannelType string `json:"channel_type,omitempty"`
ChannelSubjectID string `json:"channel_subject_id,omitempty"`
ChannelIdentityDisplayName string `json:"channel_identity_display_name,omitempty"`
ChannelIdentityAvatarURL string `json:"channel_identity_avatar_url,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Binding is a global account-level link between a web user and an IM channel identity.
type IssueLinkCodeRequest ¶
type IssueLinkCodeRequest struct {
ChannelType string `json:"channel_type,omitempty"`
}
IssueLinkCodeRequest is the body for generating a link code.
type LinkCode ¶
type LinkCode struct {
Token string `json:"token"`
UserID string `json:"user_id"`
ChannelType string `json:"channel_type,omitempty"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
}
LinkCode is a one-time code a user generates in the web app and then sends as `/link <code>` to a bot in IM to bind the sending channel identity to their account.
type ListBindingsResponse ¶
type ListBindingsResponse struct {
Items []Binding `json:"items"`
}
ListBindingsResponse wraps the connected channel identities for a user.
type ListManagersResponse ¶
type ListManagersResponse struct {
Items []Manager `json:"items"`
}
ListManagersResponse wraps the effective managers of a bot.
type Manager ¶
type Manager struct {
ChannelIdentityID string `json:"channel_identity_id"`
ChannelType string `json:"channel_type,omitempty"`
ChannelSubjectID string `json:"channel_subject_id,omitempty"`
ChannelIdentityDisplayName string `json:"channel_identity_display_name,omitempty"`
ChannelIdentityAvatarURL string `json:"channel_identity_avatar_url,omitempty"`
// Manage is the effective Manage capability (local override ?? inherited).
Manage bool `json:"manage"`
// Inherited reports whether this identity is bound to a web member that carries
// the Manage capability (owner or workspace manage grant).
Inherited bool `json:"inherited"`
// HasOverride reports whether a local Channel Access override exists for it.
HasOverride bool `json:"has_override"`
// Bound reports whether this identity is linked to a workspace member of this
// bot (any permission). It marks the identity as a "platform member" in the UI
// regardless of whether it carries Manage.
Bound bool `json:"bound"`
}
Manager is the effective Manage state for a channel identity on a bot, combining the local override (Channel Access) with the inherited grant (bound web member).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) ClearManagerOverride ¶
ClearManagerOverride removes the local Manage override so the identity falls back to inheritance.
func (*Service) ConsumeLinkCode ¶
func (s *Service) ConsumeLinkCode(ctx context.Context, token, channelIdentityID string) (Binding, error)
ConsumeLinkCode binds the given channel identity to the user that owns the code. It is invoked from the IM /link command with the sender's channel identity.
func (*Service) HasManageGrant ¶
func (s *Service) HasManageGrant(ctx context.Context, botID, channelIdentityID string) (bool, error)
HasManageGrant reports the effective Manage capability for a channel identity on a bot: a local Channel Access override wins; otherwise it is inherited when the identity is bound to a web member that carries Manage (owner or manage grant). It satisfies the command package's ChannelManageResolver.
func (*Service) IssueLinkCode ¶
IssueLinkCode generates a one-time code the user sends as /link <code> in IM.
func (*Service) ListManagers ¶
ListManagers returns the effective Manage state per channel identity on a bot, merging inherited members (bound web members carrying Manage) with local overrides.
func (*Service) ListUserBindings ¶
ListUserBindings returns the channel identities bound to a user's account.
type SetManagerRequest ¶
type SetManagerRequest struct {
ChannelIdentityID string `json:"channel_identity_id"`
// Granted forces Manage ON (true) or OFF (false) locally.
Granted bool `json:"granted"`
}
SetManagerRequest sets the local Manage override for a channel identity.