mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-06-27 14:39:24 +00:00
Update vendor (nlopes/slack)
This commit is contained in:
88
vendor/github.com/nlopes/slack/admin.go
generated
vendored
88
vendor/github.com/nlopes/slack/admin.go
generated
vendored
@ -1,6 +1,7 @@
|
||||
package slack
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
@ -11,9 +12,9 @@ type adminResponse struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
func adminRequest(method string, teamName string, values url.Values, debug bool) (*adminResponse, error) {
|
||||
func adminRequest(ctx context.Context, method string, teamName string, values url.Values, debug bool) (*adminResponse, error) {
|
||||
adminResponse := &adminResponse{}
|
||||
err := parseAdminResponse(method, teamName, values, adminResponse, debug)
|
||||
err := parseAdminResponse(ctx, method, teamName, values, adminResponse, debug)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -27,6 +28,11 @@ func adminRequest(method string, teamName string, values url.Values, debug bool)
|
||||
|
||||
// DisableUser disabled a user account, given a user ID
|
||||
func (api *Client) DisableUser(teamName string, uid string) error {
|
||||
return api.DisableUserContext(context.Background(), teamName, uid)
|
||||
}
|
||||
|
||||
// DisableUserContext disabled a user account, given a user ID with a custom context
|
||||
func (api *Client) DisableUserContext(ctx context.Context, teamName string, uid string) error {
|
||||
values := url.Values{
|
||||
"user": {uid},
|
||||
"token": {api.config.token},
|
||||
@ -34,7 +40,7 @@ func (api *Client) DisableUser(teamName string, uid string) error {
|
||||
"_attempts": {"1"},
|
||||
}
|
||||
|
||||
_, err := adminRequest("setInactive", teamName, values, api.debug)
|
||||
_, err := adminRequest(ctx, "setInactive", teamName, values, api.debug)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to disable user with id '%s': %s", uid, err)
|
||||
}
|
||||
@ -43,13 +49,12 @@ func (api *Client) DisableUser(teamName string, uid string) error {
|
||||
}
|
||||
|
||||
// InviteGuest invites a user to Slack as a single-channel guest
|
||||
func (api *Client) InviteGuest(
|
||||
teamName string,
|
||||
channel string,
|
||||
firstName string,
|
||||
lastName string,
|
||||
emailAddress string,
|
||||
) error {
|
||||
func (api *Client) InviteGuest(teamName, channel, firstName, lastName, emailAddress string) error {
|
||||
return api.InviteGuestContext(context.Background(), teamName, channel, firstName, lastName, emailAddress)
|
||||
}
|
||||
|
||||
// InviteGuestContext invites a user to Slack as a single-channel guest with a custom context
|
||||
func (api *Client) InviteGuestContext(ctx context.Context, teamName, channel, firstName, lastName, emailAddress string) error {
|
||||
values := url.Values{
|
||||
"email": {emailAddress},
|
||||
"channels": {channel},
|
||||
@ -61,7 +66,7 @@ func (api *Client) InviteGuest(
|
||||
"_attempts": {"1"},
|
||||
}
|
||||
|
||||
_, err := adminRequest("invite", teamName, values, api.debug)
|
||||
_, err := adminRequest(ctx, "invite", teamName, values, api.debug)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to invite single-channel guest: %s", err)
|
||||
}
|
||||
@ -70,13 +75,12 @@ func (api *Client) InviteGuest(
|
||||
}
|
||||
|
||||
// InviteRestricted invites a user to Slack as a restricted account
|
||||
func (api *Client) InviteRestricted(
|
||||
teamName string,
|
||||
channel string,
|
||||
firstName string,
|
||||
lastName string,
|
||||
emailAddress string,
|
||||
) error {
|
||||
func (api *Client) InviteRestricted(teamName, channel, firstName, lastName, emailAddress string) error {
|
||||
return api.InviteRestrictedContext(context.Background(), teamName, channel, firstName, lastName, emailAddress)
|
||||
}
|
||||
|
||||
// InviteRestrictedContext invites a user to Slack as a restricted account with a custom context
|
||||
func (api *Client) InviteRestrictedContext(ctx context.Context, teamName, channel, firstName, lastName, emailAddress string) error {
|
||||
values := url.Values{
|
||||
"email": {emailAddress},
|
||||
"channels": {channel},
|
||||
@ -88,7 +92,7 @@ func (api *Client) InviteRestricted(
|
||||
"_attempts": {"1"},
|
||||
}
|
||||
|
||||
_, err := adminRequest("invite", teamName, values, api.debug)
|
||||
_, err := adminRequest(ctx, "invite", teamName, values, api.debug)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to restricted account: %s", err)
|
||||
}
|
||||
@ -97,12 +101,12 @@ func (api *Client) InviteRestricted(
|
||||
}
|
||||
|
||||
// InviteToTeam invites a user to a Slack team
|
||||
func (api *Client) InviteToTeam(
|
||||
teamName string,
|
||||
firstName string,
|
||||
lastName string,
|
||||
emailAddress string,
|
||||
) error {
|
||||
func (api *Client) InviteToTeam(teamName, firstName, lastName, emailAddress string) error {
|
||||
return api.InviteToTeamContext(context.Background(), teamName, firstName, lastName, emailAddress)
|
||||
}
|
||||
|
||||
// InviteToTeamContext invites a user to a Slack team with a custom context
|
||||
func (api *Client) InviteToTeamContext(ctx context.Context, teamName, firstName, lastName, emailAddress string) error {
|
||||
values := url.Values{
|
||||
"email": {emailAddress},
|
||||
"first_name": {firstName},
|
||||
@ -112,7 +116,7 @@ func (api *Client) InviteToTeam(
|
||||
"_attempts": {"1"},
|
||||
}
|
||||
|
||||
_, err := adminRequest("invite", teamName, values, api.debug)
|
||||
_, err := adminRequest(ctx, "invite", teamName, values, api.debug)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to invite to team: %s", err)
|
||||
}
|
||||
@ -121,7 +125,12 @@ func (api *Client) InviteToTeam(
|
||||
}
|
||||
|
||||
// SetRegular enables the specified user
|
||||
func (api *Client) SetRegular(teamName string, user string) error {
|
||||
func (api *Client) SetRegular(teamName, user string) error {
|
||||
return api.SetRegularContext(context.Background(), teamName, user)
|
||||
}
|
||||
|
||||
// SetRegularContext enables the specified user with a custom context
|
||||
func (api *Client) SetRegularContext(ctx context.Context, teamName, user string) error {
|
||||
values := url.Values{
|
||||
"user": {user},
|
||||
"token": {api.config.token},
|
||||
@ -129,7 +138,7 @@ func (api *Client) SetRegular(teamName string, user string) error {
|
||||
"_attempts": {"1"},
|
||||
}
|
||||
|
||||
_, err := adminRequest("setRegular", teamName, values, api.debug)
|
||||
_, err := adminRequest(ctx, "setRegular", teamName, values, api.debug)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to change the user (%s) to a regular user: %s", user, err)
|
||||
}
|
||||
@ -138,7 +147,12 @@ func (api *Client) SetRegular(teamName string, user string) error {
|
||||
}
|
||||
|
||||
// SendSSOBindingEmail sends an SSO binding email to the specified user
|
||||
func (api *Client) SendSSOBindingEmail(teamName string, user string) error {
|
||||
func (api *Client) SendSSOBindingEmail(teamName, user string) error {
|
||||
return api.SendSSOBindingEmailContext(context.Background(), teamName, user)
|
||||
}
|
||||
|
||||
// SendSSOBindingEmailContext sends an SSO binding email to the specified user with a custom context
|
||||
func (api *Client) SendSSOBindingEmailContext(ctx context.Context, teamName, user string) error {
|
||||
values := url.Values{
|
||||
"user": {user},
|
||||
"token": {api.config.token},
|
||||
@ -146,7 +160,7 @@ func (api *Client) SendSSOBindingEmail(teamName string, user string) error {
|
||||
"_attempts": {"1"},
|
||||
}
|
||||
|
||||
_, err := adminRequest("sendSSOBind", teamName, values, api.debug)
|
||||
_, err := adminRequest(ctx, "sendSSOBind", teamName, values, api.debug)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to send SSO binding email for user (%s): %s", user, err)
|
||||
}
|
||||
@ -156,6 +170,11 @@ func (api *Client) SendSSOBindingEmail(teamName string, user string) error {
|
||||
|
||||
// SetUltraRestricted converts a user into a single-channel guest
|
||||
func (api *Client) SetUltraRestricted(teamName, uid, channel string) error {
|
||||
return api.SetUltraRestrictedContext(context.Background(), teamName, uid, channel)
|
||||
}
|
||||
|
||||
// SetUltraRestrictedContext converts a user into a single-channel guest with a custom context
|
||||
func (api *Client) SetUltraRestrictedContext(ctx context.Context, teamName, uid, channel string) error {
|
||||
values := url.Values{
|
||||
"user": {uid},
|
||||
"channel": {channel},
|
||||
@ -164,7 +183,7 @@ func (api *Client) SetUltraRestricted(teamName, uid, channel string) error {
|
||||
"_attempts": {"1"},
|
||||
}
|
||||
|
||||
_, err := adminRequest("setUltraRestricted", teamName, values, api.debug)
|
||||
_, err := adminRequest(ctx, "setUltraRestricted", teamName, values, api.debug)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to ultra-restrict account: %s", err)
|
||||
}
|
||||
@ -174,6 +193,11 @@ func (api *Client) SetUltraRestricted(teamName, uid, channel string) error {
|
||||
|
||||
// SetRestricted converts a user into a restricted account
|
||||
func (api *Client) SetRestricted(teamName, uid string) error {
|
||||
return api.SetRestrictedContext(context.Background(), teamName, uid)
|
||||
}
|
||||
|
||||
// SetRestrictedContext converts a user into a restricted account with a custom context
|
||||
func (api *Client) SetRestrictedContext(ctx context.Context, teamName, uid string) error {
|
||||
values := url.Values{
|
||||
"user": {uid},
|
||||
"token": {api.config.token},
|
||||
@ -181,7 +205,7 @@ func (api *Client) SetRestricted(teamName, uid string) error {
|
||||
"_attempts": {"1"},
|
||||
}
|
||||
|
||||
_, err := adminRequest("setRestricted", teamName, values, api.debug)
|
||||
_, err := adminRequest(ctx, "setRestricted", teamName, values, api.debug)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to restrict account: %s", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user