mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-03 22:27:44 +00:00
Update dependencies (#1813)
This commit is contained in:
6
vendor/github.com/slack-go/slack/apps.go
generated
vendored
6
vendor/github.com/slack-go/slack/apps.go
generated
vendored
@ -44,6 +44,10 @@ func (api *Client) ListEventAuthorizationsContext(ctx context.Context, eventCont
|
||||
}
|
||||
|
||||
func (api *Client) UninstallApp(clientID, clientSecret string) error {
|
||||
return api.UninstallAppContext(context.Background(), clientID, clientSecret)
|
||||
}
|
||||
|
||||
func (api *Client) UninstallAppContext(ctx context.Context, clientID, clientSecret string) error {
|
||||
values := url.Values{
|
||||
"client_id": {clientID},
|
||||
"client_secret": {clientSecret},
|
||||
@ -51,7 +55,7 @@ func (api *Client) UninstallApp(clientID, clientSecret string) error {
|
||||
|
||||
response := SlackResponse{}
|
||||
|
||||
err := api.getMethod(context.Background(), "apps.uninstall", api.token, values, &response)
|
||||
err := api.getMethod(ctx, "apps.uninstall", api.token, values, &response)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
10
vendor/github.com/slack-go/slack/audit.go
generated
vendored
10
vendor/github.com/slack-go/slack/audit.go
generated
vendored
@ -39,6 +39,16 @@ type AuditEntry struct {
|
||||
UA string `json:"ua"`
|
||||
IPAddress string `json:"ip_address"`
|
||||
} `json:"context"`
|
||||
Details struct {
|
||||
NewValue interface{} `json:"new_value"`
|
||||
PreviousValue interface{} `json:"previous_value"`
|
||||
MobileOnly bool `json:"mobile_only"`
|
||||
WebOnly bool `json:"web_only"`
|
||||
NonSSOOnly bool `json:"non_sso_only"`
|
||||
ExportType string `json:"export_type"`
|
||||
ExportStart string `json:"export_start_ts"`
|
||||
ExportEnd string `json:"export_end_ts"`
|
||||
} `json:"details"`
|
||||
}
|
||||
|
||||
type AuditUser struct {
|
||||
|
6
vendor/github.com/slack-go/slack/block_element.go
generated
vendored
6
vendor/github.com/slack-go/slack/block_element.go
generated
vendored
@ -167,6 +167,12 @@ func (s *ButtonBlockElement) WithStyle(style Style) *ButtonBlockElement {
|
||||
return s
|
||||
}
|
||||
|
||||
// WithConfirm adds a confirmation dialogue to the button object and returns the modified ButtonBlockElement
|
||||
func (s *ButtonBlockElement) WithConfirm(confirm *ConfirmationBlockObject) *ButtonBlockElement {
|
||||
s.Confirm = confirm
|
||||
return s
|
||||
}
|
||||
|
||||
// NewButtonBlockElement returns an instance of a new button element to be used within a block
|
||||
func NewButtonBlockElement(actionID, value string, text *TextBlockObject) *ButtonBlockElement {
|
||||
return &ButtonBlockElement{
|
||||
|
3
vendor/github.com/slack-go/slack/block_object.go
generated
vendored
3
vendor/github.com/slack-go/slack/block_object.go
generated
vendored
@ -187,8 +187,9 @@ func (s ConfirmationBlockObject) validateType() MessageObjectType {
|
||||
}
|
||||
|
||||
// WithStyle add styling to confirmation object
|
||||
func (s *ConfirmationBlockObject) WithStyle(style Style) {
|
||||
func (s *ConfirmationBlockObject) WithStyle(style Style) *ConfirmationBlockObject {
|
||||
s.Style = style
|
||||
return s
|
||||
}
|
||||
|
||||
// NewConfirmationBlockObject returns an instance of a new Confirmation Block Object
|
||||
|
60
vendor/github.com/slack-go/slack/chat.go
generated
vendored
60
vendor/github.com/slack-go/slack/chat.go
generated
vendored
@ -86,12 +86,7 @@ func NewPostMessageParameters() PostMessageParameters {
|
||||
|
||||
// DeleteMessage deletes a message in a channel
|
||||
func (api *Client) DeleteMessage(channel, messageTimestamp string) (string, string, error) {
|
||||
respChannel, respTimestamp, _, err := api.SendMessageContext(
|
||||
context.Background(),
|
||||
channel,
|
||||
MsgOptionDelete(messageTimestamp),
|
||||
)
|
||||
return respChannel, respTimestamp, err
|
||||
return api.DeleteMessageContext(context.Background(), channel, messageTimestamp)
|
||||
}
|
||||
|
||||
// DeleteMessageContext deletes a message in a channel with a custom context
|
||||
@ -108,8 +103,15 @@ func (api *Client) DeleteMessageContext(ctx context.Context, channel, messageTim
|
||||
// Message is escaped by default according to https://api.slack.com/docs/formatting
|
||||
// Use http://davestevens.github.io/slack-message-builder/ to help crafting your message.
|
||||
func (api *Client) ScheduleMessage(channelID, postAt string, options ...MsgOption) (string, string, error) {
|
||||
return api.ScheduleMessageContext(context.Background(), channelID, postAt, options...)
|
||||
}
|
||||
|
||||
// ScheduleMessageContext sends a message to a channel with a custom context
|
||||
//
|
||||
// For more details, see ScheduleMessage documentation.
|
||||
func (api *Client) ScheduleMessageContext(ctx context.Context, channelID, postAt string, options ...MsgOption) (string, string, error) {
|
||||
respChannel, respTimestamp, _, err := api.SendMessageContext(
|
||||
context.Background(),
|
||||
ctx,
|
||||
channelID,
|
||||
MsgOptionSchedule(postAt),
|
||||
MsgOptionCompose(options...),
|
||||
@ -121,13 +123,7 @@ func (api *Client) ScheduleMessage(channelID, postAt string, options ...MsgOptio
|
||||
// Message is escaped by default according to https://api.slack.com/docs/formatting
|
||||
// Use http://davestevens.github.io/slack-message-builder/ to help crafting your message.
|
||||
func (api *Client) PostMessage(channelID string, options ...MsgOption) (string, string, error) {
|
||||
respChannel, respTimestamp, _, err := api.SendMessageContext(
|
||||
context.Background(),
|
||||
channelID,
|
||||
MsgOptionPost(),
|
||||
MsgOptionCompose(options...),
|
||||
)
|
||||
return respChannel, respTimestamp, err
|
||||
return api.PostMessageContext(context.Background(), channelID, options...)
|
||||
}
|
||||
|
||||
// PostMessageContext sends a message to a channel with a custom context
|
||||
@ -146,12 +142,7 @@ func (api *Client) PostMessageContext(ctx context.Context, channelID string, opt
|
||||
// Message is escaped by default according to https://api.slack.com/docs/formatting
|
||||
// Use http://davestevens.github.io/slack-message-builder/ to help crafting your message.
|
||||
func (api *Client) PostEphemeral(channelID, userID string, options ...MsgOption) (string, error) {
|
||||
return api.PostEphemeralContext(
|
||||
context.Background(),
|
||||
channelID,
|
||||
userID,
|
||||
options...,
|
||||
)
|
||||
return api.PostEphemeralContext(context.Background(), channelID, userID, options...)
|
||||
}
|
||||
|
||||
// PostEphemeralContext sends an ephemeal message to a user in a channel with a custom context
|
||||
@ -168,12 +159,7 @@ func (api *Client) PostEphemeralContext(ctx context.Context, channelID, userID s
|
||||
|
||||
// UpdateMessage updates a message in a channel
|
||||
func (api *Client) UpdateMessage(channelID, timestamp string, options ...MsgOption) (string, string, string, error) {
|
||||
return api.SendMessageContext(
|
||||
context.Background(),
|
||||
channelID,
|
||||
MsgOptionUpdate(timestamp),
|
||||
MsgOptionCompose(options...),
|
||||
)
|
||||
return api.UpdateMessageContext(context.Background(), channelID, timestamp, options...)
|
||||
}
|
||||
|
||||
// UpdateMessageContext updates a message in a channel
|
||||
@ -225,7 +211,7 @@ func (api *Client) SendMessageContext(ctx context.Context, channelID string, opt
|
||||
response chatResponseFull
|
||||
)
|
||||
|
||||
if req, parser, err = buildSender(api.endpoint, options...).BuildRequest(api.token, channelID); err != nil {
|
||||
if req, parser, err = buildSender(api.endpoint, options...).BuildRequestContext(ctx, api.token, channelID); err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
|
||||
@ -306,6 +292,10 @@ type sendConfig struct {
|
||||
}
|
||||
|
||||
func (t sendConfig) BuildRequest(token, channelID string) (req *http.Request, _ func(*chatResponseFull) responseParser, err error) {
|
||||
return t.BuildRequestContext(context.Background(), token, channelID)
|
||||
}
|
||||
|
||||
func (t sendConfig) BuildRequestContext(ctx context.Context, token, channelID string) (req *http.Request, _ func(*chatResponseFull) responseParser, err error) {
|
||||
if t, err = applyMsgOptions(token, channelID, t.apiurl, t.options...); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -320,9 +310,9 @@ func (t sendConfig) BuildRequest(token, channelID string) (req *http.Request, _
|
||||
responseType: t.responseType,
|
||||
replaceOriginal: t.replaceOriginal,
|
||||
deleteOriginal: t.deleteOriginal,
|
||||
}.BuildRequest()
|
||||
}.BuildRequestContext(ctx)
|
||||
default:
|
||||
return formSender{endpoint: t.endpoint, values: t.values}.BuildRequest()
|
||||
return formSender{endpoint: t.endpoint, values: t.values}.BuildRequestContext(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,7 +322,11 @@ type formSender struct {
|
||||
}
|
||||
|
||||
func (t formSender) BuildRequest() (*http.Request, func(*chatResponseFull) responseParser, error) {
|
||||
req, err := formReq(t.endpoint, t.values)
|
||||
return t.BuildRequestContext(context.Background())
|
||||
}
|
||||
|
||||
func (t formSender) BuildRequestContext(ctx context.Context) (*http.Request, func(*chatResponseFull) responseParser, error) {
|
||||
req, err := formReq(ctx, t.endpoint, t.values)
|
||||
return req, func(resp *chatResponseFull) responseParser {
|
||||
return newJSONParser(resp)
|
||||
}, err
|
||||
@ -349,7 +343,11 @@ type responseURLSender struct {
|
||||
}
|
||||
|
||||
func (t responseURLSender) BuildRequest() (*http.Request, func(*chatResponseFull) responseParser, error) {
|
||||
req, err := jsonReq(t.endpoint, Msg{
|
||||
return t.BuildRequestContext(context.Background())
|
||||
}
|
||||
|
||||
func (t responseURLSender) BuildRequestContext(ctx context.Context) (*http.Request, func(*chatResponseFull) responseParser, error) {
|
||||
req, err := jsonReq(ctx, t.endpoint, Msg{
|
||||
Text: t.values.Get("text"),
|
||||
Timestamp: t.values.Get("ts"),
|
||||
Attachments: t.attachments,
|
||||
|
79
vendor/github.com/slack-go/slack/files.go
generated
vendored
79
vendor/github.com/slack-go/slack/files.go
generated
vendored
@ -202,7 +202,14 @@ func (api *Client) GetFileInfoContext(ctx context.Context, fileID string, count,
|
||||
|
||||
// GetFile retreives a given file from its private download URL
|
||||
func (api *Client) GetFile(downloadURL string, writer io.Writer) error {
|
||||
return downloadFile(api.httpclient, api.token, downloadURL, writer, api)
|
||||
return api.GetFileContext(context.Background(), downloadURL, writer)
|
||||
}
|
||||
|
||||
// GetFileContext retreives a given file from its private download URL with a custom context
|
||||
//
|
||||
// For more details, see GetFile documentation.
|
||||
func (api *Client) GetFileContext(ctx context.Context, downloadURL string, writer io.Writer) error {
|
||||
return downloadFile(ctx, api.httpclient, api.token, downloadURL, writer, api)
|
||||
}
|
||||
|
||||
// GetFiles retrieves all files according to the parameters given
|
||||
@ -210,40 +217,6 @@ func (api *Client) GetFiles(params GetFilesParameters) ([]File, *Paging, error)
|
||||
return api.GetFilesContext(context.Background(), params)
|
||||
}
|
||||
|
||||
// ListFiles retrieves all files according to the parameters given. Uses cursor based pagination.
|
||||
func (api *Client) ListFiles(params ListFilesParameters) ([]File, *ListFilesParameters, error) {
|
||||
return api.ListFilesContext(context.Background(), params)
|
||||
}
|
||||
|
||||
// ListFilesContext retrieves all files according to the parameters given with a custom context. Uses cursor based pagination.
|
||||
func (api *Client) ListFilesContext(ctx context.Context, params ListFilesParameters) ([]File, *ListFilesParameters, error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
}
|
||||
|
||||
if params.User != DEFAULT_FILES_USER {
|
||||
values.Add("user", params.User)
|
||||
}
|
||||
if params.Channel != DEFAULT_FILES_CHANNEL {
|
||||
values.Add("channel", params.Channel)
|
||||
}
|
||||
if params.Limit != DEFAULT_FILES_COUNT {
|
||||
values.Add("limit", strconv.Itoa(params.Limit))
|
||||
}
|
||||
if params.Cursor != "" {
|
||||
values.Add("cursor", params.Cursor)
|
||||
}
|
||||
|
||||
response, err := api.fileRequest(ctx, "files.list", values)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
params.Cursor = response.Metadata.Cursor
|
||||
|
||||
return response.Files, ¶ms, nil
|
||||
}
|
||||
|
||||
// GetFilesContext retrieves all files according to the parameters given with a custom context
|
||||
func (api *Client) GetFilesContext(ctx context.Context, params GetFilesParameters) ([]File, *Paging, error) {
|
||||
values := url.Values{
|
||||
@ -281,6 +254,42 @@ func (api *Client) GetFilesContext(ctx context.Context, params GetFilesParameter
|
||||
return response.Files, &response.Paging, nil
|
||||
}
|
||||
|
||||
// ListFiles retrieves all files according to the parameters given. Uses cursor based pagination.
|
||||
func (api *Client) ListFiles(params ListFilesParameters) ([]File, *ListFilesParameters, error) {
|
||||
return api.ListFilesContext(context.Background(), params)
|
||||
}
|
||||
|
||||
// ListFilesContext retrieves all files according to the parameters given with a custom context.
|
||||
//
|
||||
// For more details, see ListFiles documentation.
|
||||
func (api *Client) ListFilesContext(ctx context.Context, params ListFilesParameters) ([]File, *ListFilesParameters, error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
}
|
||||
|
||||
if params.User != DEFAULT_FILES_USER {
|
||||
values.Add("user", params.User)
|
||||
}
|
||||
if params.Channel != DEFAULT_FILES_CHANNEL {
|
||||
values.Add("channel", params.Channel)
|
||||
}
|
||||
if params.Limit != DEFAULT_FILES_COUNT {
|
||||
values.Add("limit", strconv.Itoa(params.Limit))
|
||||
}
|
||||
if params.Cursor != "" {
|
||||
values.Add("cursor", params.Cursor)
|
||||
}
|
||||
|
||||
response, err := api.fileRequest(ctx, "files.list", values)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
params.Cursor = response.Metadata.Cursor
|
||||
|
||||
return response.Files, ¶ms, nil
|
||||
}
|
||||
|
||||
// UploadFile uploads a file
|
||||
func (api *Client) UploadFile(params FileUploadParameters) (file *File, err error) {
|
||||
return api.UploadFileContext(context.Background(), params)
|
||||
|
6
vendor/github.com/slack-go/slack/info.go
generated
vendored
6
vendor/github.com/slack-go/slack/info.go
generated
vendored
@ -321,9 +321,13 @@ type UserPrefs struct {
|
||||
}
|
||||
|
||||
func (api *Client) GetUserPrefs() (*UserPrefsCarrier, error) {
|
||||
return api.GetUserPrefsContext(context.Background())
|
||||
}
|
||||
|
||||
func (api *Client) GetUserPrefsContext(ctx context.Context) (*UserPrefsCarrier, error) {
|
||||
response := UserPrefsCarrier{}
|
||||
|
||||
err := api.getMethod(context.Background(), "users.prefs.get", api.token, url.Values{}, &response)
|
||||
err := api.getMethod(ctx, "users.prefs.get", api.token, url.Values{}, &response)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
54
vendor/github.com/slack-go/slack/interactions.go
generated
vendored
54
vendor/github.com/slack-go/slack/interactions.go
generated
vendored
@ -28,32 +28,34 @@ const (
|
||||
InteractionTypeViewSubmission = InteractionType("view_submission")
|
||||
InteractionTypeViewClosed = InteractionType("view_closed")
|
||||
InteractionTypeShortcut = InteractionType("shortcut")
|
||||
InteractionTypeWorkflowStepEdit = InteractionType("workflow_step_edit")
|
||||
)
|
||||
|
||||
// InteractionCallback is sent from slack when a user interactions with a button or dialog.
|
||||
type InteractionCallback struct {
|
||||
Type InteractionType `json:"type"`
|
||||
Token string `json:"token"`
|
||||
CallbackID string `json:"callback_id"`
|
||||
ResponseURL string `json:"response_url"`
|
||||
TriggerID string `json:"trigger_id"`
|
||||
ActionTs string `json:"action_ts"`
|
||||
Team Team `json:"team"`
|
||||
Channel Channel `json:"channel"`
|
||||
User User `json:"user"`
|
||||
OriginalMessage Message `json:"original_message"`
|
||||
Message Message `json:"message"`
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value"`
|
||||
MessageTs string `json:"message_ts"`
|
||||
AttachmentID string `json:"attachment_id"`
|
||||
ActionCallback ActionCallbacks `json:"actions"`
|
||||
View View `json:"view"`
|
||||
ActionID string `json:"action_id"`
|
||||
APIAppID string `json:"api_app_id"`
|
||||
BlockID string `json:"block_id"`
|
||||
Container Container `json:"container"`
|
||||
Enterprise Enterprise `json:"enterprise"`
|
||||
Type InteractionType `json:"type"`
|
||||
Token string `json:"token"`
|
||||
CallbackID string `json:"callback_id"`
|
||||
ResponseURL string `json:"response_url"`
|
||||
TriggerID string `json:"trigger_id"`
|
||||
ActionTs string `json:"action_ts"`
|
||||
Team Team `json:"team"`
|
||||
Channel Channel `json:"channel"`
|
||||
User User `json:"user"`
|
||||
OriginalMessage Message `json:"original_message"`
|
||||
Message Message `json:"message"`
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value"`
|
||||
MessageTs string `json:"message_ts"`
|
||||
AttachmentID string `json:"attachment_id"`
|
||||
ActionCallback ActionCallbacks `json:"actions"`
|
||||
View View `json:"view"`
|
||||
ActionID string `json:"action_id"`
|
||||
APIAppID string `json:"api_app_id"`
|
||||
BlockID string `json:"block_id"`
|
||||
Container Container `json:"container"`
|
||||
Enterprise Enterprise `json:"enterprise"`
|
||||
WorkflowStep InteractionWorkflowStep `json:"workflow_step"`
|
||||
DialogSubmissionCallback
|
||||
ViewSubmissionCallback
|
||||
ViewClosedCallback
|
||||
@ -134,6 +136,14 @@ type Enterprise struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type InteractionWorkflowStep struct {
|
||||
WorkflowStepEditID string `json:"workflow_step_edit_id,omitempty"`
|
||||
WorkflowID string `json:"workflow_id"`
|
||||
StepID string `json:"step_id"`
|
||||
Inputs *WorkflowStepInputs `json:"inputs,omitempty"`
|
||||
Outputs *[]WorkflowStepOutput `json:"outputs,omitempty"`
|
||||
}
|
||||
|
||||
// ActionCallback is a convenience struct defined to allow dynamic unmarshalling of
|
||||
// the "actions" value in Slack's JSON response, which varies depending on block type
|
||||
type ActionCallbacks struct {
|
||||
|
20
vendor/github.com/slack-go/slack/messageID.go
generated
vendored
20
vendor/github.com/slack-go/slack/messageID.go
generated
vendored
@ -1,6 +1,6 @@
|
||||
package slack
|
||||
|
||||
import "sync"
|
||||
import "sync/atomic"
|
||||
|
||||
// IDGenerator provides an interface for generating integer ID values.
|
||||
type IDGenerator interface {
|
||||
@ -11,20 +11,20 @@ type IDGenerator interface {
|
||||
// concurrent use by multiple goroutines.
|
||||
func NewSafeID(startID int) IDGenerator {
|
||||
return &safeID{
|
||||
nextID: startID,
|
||||
mutex: &sync.Mutex{},
|
||||
nextID: int64(startID),
|
||||
}
|
||||
}
|
||||
|
||||
type safeID struct {
|
||||
nextID int
|
||||
mutex *sync.Mutex
|
||||
nextID int64
|
||||
}
|
||||
|
||||
// make sure safeID implements the IDGenerator interface.
|
||||
var _ IDGenerator = (*safeID)(nil)
|
||||
|
||||
// Next implements IDGenerator.Next.
|
||||
func (s *safeID) Next() int {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
id := s.nextID
|
||||
s.nextID++
|
||||
return id
|
||||
id := atomic.AddInt64(&s.nextID, 1)
|
||||
|
||||
return int(id)
|
||||
}
|
||||
|
26
vendor/github.com/slack-go/slack/misc.go
generated
vendored
26
vendor/github.com/slack-go/slack/misc.go
generated
vendored
@ -66,29 +66,27 @@ func (e *RateLimitedError) Retryable() bool {
|
||||
}
|
||||
|
||||
func fileUploadReq(ctx context.Context, path string, values url.Values, r io.Reader) (*http.Request, error) {
|
||||
req, err := http.NewRequest("POST", path, r)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, path, r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req = req.WithContext(ctx)
|
||||
req.URL.RawQuery = (values).Encode()
|
||||
req.URL.RawQuery = values.Encode()
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func downloadFile(client httpClient, token string, downloadURL string, writer io.Writer, d Debug) error {
|
||||
func downloadFile(ctx context.Context, client httpClient, token string, downloadURL string, writer io.Writer, d Debug) error {
|
||||
if downloadURL == "" {
|
||||
return fmt.Errorf("received empty download URL")
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("GET", downloadURL, &bytes.Buffer{})
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, downloadURL, &bytes.Buffer{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var bearer = "Bearer " + token
|
||||
req.Header.Add("Authorization", bearer)
|
||||
req.WithContext(context.Background())
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
@ -107,8 +105,8 @@ func downloadFile(client httpClient, token string, downloadURL string, writer io
|
||||
return err
|
||||
}
|
||||
|
||||
func formReq(endpoint string, values url.Values) (req *http.Request, err error) {
|
||||
if req, err = http.NewRequest("POST", endpoint, strings.NewReader(values.Encode())); err != nil {
|
||||
func formReq(ctx context.Context, endpoint string, values url.Values) (req *http.Request, err error) {
|
||||
if req, err = http.NewRequestWithContext(ctx, http.MethodPost, endpoint, strings.NewReader(values.Encode())); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -116,13 +114,13 @@ func formReq(endpoint string, values url.Values) (req *http.Request, err error)
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func jsonReq(endpoint string, body interface{}) (req *http.Request, err error) {
|
||||
func jsonReq(ctx context.Context, endpoint string, body interface{}) (req *http.Request, err error) {
|
||||
buffer := bytes.NewBuffer([]byte{})
|
||||
if err = json.NewEncoder(buffer).Encode(body); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if req, err = http.NewRequest("POST", endpoint, buffer); err != nil {
|
||||
if req, err = http.NewRequestWithContext(ctx, http.MethodPost, endpoint, buffer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -184,7 +182,6 @@ func postWithMultipartResponse(ctx context.Context, client httpClient, path, nam
|
||||
}
|
||||
req.Header.Add("Content-Type", wr.FormDataContentType())
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||
req = req.WithContext(ctx)
|
||||
resp, err := client.Do(req)
|
||||
|
||||
if err != nil {
|
||||
@ -206,7 +203,6 @@ func postWithMultipartResponse(ctx context.Context, client httpClient, path, nam
|
||||
}
|
||||
|
||||
func doPost(ctx context.Context, client httpClient, req *http.Request, parser responseParser, d Debug) error {
|
||||
req = req.WithContext(ctx)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -224,7 +220,7 @@ func doPost(ctx context.Context, client httpClient, req *http.Request, parser re
|
||||
// post JSON.
|
||||
func postJSON(ctx context.Context, client httpClient, endpoint, token string, json []byte, intf interface{}, d Debug) error {
|
||||
reqBody := bytes.NewBuffer(json)
|
||||
req, err := http.NewRequest("POST", endpoint, reqBody)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, reqBody)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -237,7 +233,7 @@ func postJSON(ctx context.Context, client httpClient, endpoint, token string, js
|
||||
// post a url encoded form.
|
||||
func postForm(ctx context.Context, client httpClient, endpoint string, values url.Values, intf interface{}, d Debug) error {
|
||||
reqBody := strings.NewReader(values.Encode())
|
||||
req, err := http.NewRequest("POST", endpoint, reqBody)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, reqBody)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -246,7 +242,7 @@ func postForm(ctx context.Context, client httpClient, endpoint string, values ur
|
||||
}
|
||||
|
||||
func getResource(ctx context.Context, client httpClient, endpoint, token string, values url.Values, intf interface{}, d Debug) error {
|
||||
req, err := http.NewRequest("GET", endpoint, nil)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
36
vendor/github.com/slack-go/slack/reminders.go
generated
vendored
36
vendor/github.com/slack-go/slack/reminders.go
generated
vendored
@ -52,10 +52,17 @@ func (api *Client) doReminders(ctx context.Context, path string, values url.Valu
|
||||
//
|
||||
// See https://api.slack.com/methods/reminders.list
|
||||
func (api *Client) ListReminders() ([]*Reminder, error) {
|
||||
return api.ListRemindersContext(context.Background())
|
||||
}
|
||||
|
||||
// ListRemindersContext lists all the reminders created by or for the authenticated user with a custom context
|
||||
//
|
||||
// For more details, see ListReminders documentation.
|
||||
func (api *Client) ListRemindersContext(ctx context.Context) ([]*Reminder, error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
}
|
||||
return api.doReminders(context.Background(), "reminders.list", values)
|
||||
return api.doReminders(ctx, "reminders.list", values)
|
||||
}
|
||||
|
||||
// AddChannelReminder adds a reminder for a channel.
|
||||
@ -64,13 +71,20 @@ func (api *Client) ListReminders() ([]*Reminder, error) {
|
||||
// reminders on a channel is currently undocumented but has been tested to
|
||||
// work)
|
||||
func (api *Client) AddChannelReminder(channelID, text, time string) (*Reminder, error) {
|
||||
return api.AddChannelReminderContext(context.Background(), channelID, text, time)
|
||||
}
|
||||
|
||||
// AddChannelReminderContext adds a reminder for a channel with a custom context
|
||||
//
|
||||
// For more details, see AddChannelReminder documentation.
|
||||
func (api *Client) AddChannelReminderContext(ctx context.Context, channelID, text, time string) (*Reminder, error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
"text": {text},
|
||||
"time": {time},
|
||||
"channel": {channelID},
|
||||
}
|
||||
return api.doReminder(context.Background(), "reminders.add", values)
|
||||
return api.doReminder(ctx, "reminders.add", values)
|
||||
}
|
||||
|
||||
// AddUserReminder adds a reminder for a user.
|
||||
@ -79,25 +93,39 @@ func (api *Client) AddChannelReminder(channelID, text, time string) (*Reminder,
|
||||
// reminders on a channel is currently undocumented but has been tested to
|
||||
// work)
|
||||
func (api *Client) AddUserReminder(userID, text, time string) (*Reminder, error) {
|
||||
return api.AddUserReminderContext(context.Background(), userID, text, time)
|
||||
}
|
||||
|
||||
// AddUserReminderContext adds a reminder for a user with a custom context
|
||||
//
|
||||
// For more details, see AddUserReminder documentation.
|
||||
func (api *Client) AddUserReminderContext(ctx context.Context, userID, text, time string) (*Reminder, error) {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
"text": {text},
|
||||
"time": {time},
|
||||
"user": {userID},
|
||||
}
|
||||
return api.doReminder(context.Background(), "reminders.add", values)
|
||||
return api.doReminder(ctx, "reminders.add", values)
|
||||
}
|
||||
|
||||
// DeleteReminder deletes an existing reminder.
|
||||
//
|
||||
// See https://api.slack.com/methods/reminders.delete
|
||||
func (api *Client) DeleteReminder(id string) error {
|
||||
return api.DeleteReminderContext(context.Background(), id)
|
||||
}
|
||||
|
||||
// DeleteReminderContext deletes an existing reminder with a custom context
|
||||
//
|
||||
// For more details, see DeleteReminder documentation.
|
||||
func (api *Client) DeleteReminderContext(ctx context.Context, id string) error {
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
"reminder": {id},
|
||||
}
|
||||
response := &SlackResponse{}
|
||||
if err := api.postMethod(context.Background(), "reminders.delete", values, response); err != nil {
|
||||
if err := api.postMethod(ctx, "reminders.delete", values, response); err != nil {
|
||||
return err
|
||||
}
|
||||
return response.Err()
|
||||
|
6
vendor/github.com/slack-go/slack/slackutilsx/slackutilsx.go
generated
vendored
6
vendor/github.com/slack-go/slack/slackutilsx/slackutilsx.go
generated
vendored
@ -50,10 +50,12 @@ func DetectChannelType(channelID string) ChannelType {
|
||||
}
|
||||
}
|
||||
|
||||
// initialize replacer only once (if needed)
|
||||
var escapeReplacer = strings.NewReplacer("&", "&", "<", "<", ">", ">")
|
||||
|
||||
// EscapeMessage text
|
||||
func EscapeMessage(message string) string {
|
||||
replacer := strings.NewReplacer("&", "&", "<", "<", ">", ">")
|
||||
return replacer.Replace(message)
|
||||
return escapeReplacer.Replace(message)
|
||||
}
|
||||
|
||||
// Retryable errors return true.
|
||||
|
2
vendor/github.com/slack-go/slack/views.go
generated
vendored
2
vendor/github.com/slack-go/slack/views.go
generated
vendored
@ -98,7 +98,7 @@ func NewErrorsViewSubmissionResponse(errors map[string]string) *ViewSubmissionRe
|
||||
|
||||
type ModalViewRequest struct {
|
||||
Type ViewType `json:"type"`
|
||||
Title *TextBlockObject `json:"title"`
|
||||
Title *TextBlockObject `json:"title,omitempty"`
|
||||
Blocks Blocks `json:"blocks"`
|
||||
Close *TextBlockObject `json:"close,omitempty"`
|
||||
Submit *TextBlockObject `json:"submit,omitempty"`
|
||||
|
24
vendor/github.com/slack-go/slack/webhooks.go
generated
vendored
24
vendor/github.com/slack-go/slack/webhooks.go
generated
vendored
@ -1,7 +1,10 @@
|
||||
package slack
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@ -31,3 +34,24 @@ func PostWebhookContext(ctx context.Context, url string, msg *WebhookMessage) er
|
||||
func PostWebhookCustomHTTP(url string, httpClient *http.Client, msg *WebhookMessage) error {
|
||||
return PostWebhookCustomHTTPContext(context.Background(), url, httpClient, msg)
|
||||
}
|
||||
|
||||
func PostWebhookCustomHTTPContext(ctx context.Context, url string, httpClient *http.Client, msg *WebhookMessage) error {
|
||||
raw, err := json.Marshal(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("marshal failed: %w", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(raw))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed new request: %w", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to post webhook: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
return checkStatusCode(resp, discard{})
|
||||
}
|
||||
|
34
vendor/github.com/slack-go/slack/webhooks_go112.go
generated
vendored
34
vendor/github.com/slack-go/slack/webhooks_go112.go
generated
vendored
@ -1,34 +0,0 @@
|
||||
//go:build !go1.13
|
||||
// +build !go1.13
|
||||
|
||||
package slack
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func PostWebhookCustomHTTPContext(ctx context.Context, url string, httpClient *http.Client, msg *WebhookMessage) error {
|
||||
raw, err := json.Marshal(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("marshal failed: %v", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(raw))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed new request: %v", err)
|
||||
}
|
||||
req = req.WithContext(ctx)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to post webhook: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
return checkStatusCode(resp, discard{})
|
||||
}
|
33
vendor/github.com/slack-go/slack/webhooks_go113.go
generated
vendored
33
vendor/github.com/slack-go/slack/webhooks_go113.go
generated
vendored
@ -1,33 +0,0 @@
|
||||
//go:build go1.13
|
||||
// +build go1.13
|
||||
|
||||
package slack
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func PostWebhookCustomHTTPContext(ctx context.Context, url string, httpClient *http.Client, msg *WebhookMessage) error {
|
||||
raw, err := json.Marshal(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("marshal failed: %w", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(raw))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed new request: %w", err)
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to post webhook: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
return checkStatusCode(resp, discard{})
|
||||
}
|
6
vendor/github.com/slack-go/slack/websocket_managed_conn.go
generated
vendored
6
vendor/github.com/slack-go/slack/websocket_managed_conn.go
generated
vendored
@ -9,11 +9,11 @@ import (
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/slack-go/slack/internal/backoff"
|
||||
"github.com/slack-go/slack/internal/misc"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
|
||||
"github.com/slack-go/slack/internal/backoff"
|
||||
"github.com/slack-go/slack/internal/errorsx"
|
||||
"github.com/slack-go/slack/internal/misc"
|
||||
"github.com/slack-go/slack/internal/timex"
|
||||
)
|
||||
|
||||
|
98
vendor/github.com/slack-go/slack/workflow_step.go
generated
vendored
Normal file
98
vendor/github.com/slack-go/slack/workflow_step.go
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
package slack
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
const VTWorkflowStep ViewType = "workflow_step"
|
||||
|
||||
type (
|
||||
ConfigurationModalRequest struct {
|
||||
ModalViewRequest
|
||||
}
|
||||
|
||||
WorkflowStepCompleteResponse struct {
|
||||
WorkflowStepEditID string `json:"workflow_step_edit_id"`
|
||||
Inputs *WorkflowStepInputs `json:"inputs,omitempty"`
|
||||
Outputs *[]WorkflowStepOutput `json:"outputs,omitempty"`
|
||||
}
|
||||
|
||||
WorkflowStepInputElement struct {
|
||||
Value string `json:"value"`
|
||||
SkipVariableReplacement bool `json:"skip_variable_replacement"`
|
||||
}
|
||||
|
||||
WorkflowStepInputs map[string]WorkflowStepInputElement
|
||||
|
||||
WorkflowStepOutput struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
)
|
||||
|
||||
func NewConfigurationModalRequest(blocks Blocks, privateMetaData string, externalID string) *ConfigurationModalRequest {
|
||||
return &ConfigurationModalRequest{
|
||||
ModalViewRequest{
|
||||
Type: VTWorkflowStep,
|
||||
Title: nil, // slack configuration modal must not have a title!
|
||||
Blocks: blocks,
|
||||
PrivateMetadata: privateMetaData,
|
||||
ExternalID: externalID,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (api *Client) SaveWorkflowStepConfiguration(workflowStepEditID string, inputs *WorkflowStepInputs, outputs *[]WorkflowStepOutput) error {
|
||||
return api.SaveWorkflowStepConfigurationContext(context.Background(), workflowStepEditID, inputs, outputs)
|
||||
}
|
||||
|
||||
func (api *Client) SaveWorkflowStepConfigurationContext(ctx context.Context, workflowStepEditID string, inputs *WorkflowStepInputs, outputs *[]WorkflowStepOutput) error {
|
||||
// More information: https://api.slack.com/methods/workflows.updateStep
|
||||
wscr := WorkflowStepCompleteResponse{
|
||||
WorkflowStepEditID: workflowStepEditID,
|
||||
Inputs: inputs,
|
||||
Outputs: outputs,
|
||||
}
|
||||
|
||||
endpoint := api.endpoint + "workflows.updateStep"
|
||||
jsonData, err := json.Marshal(wscr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
response := &SlackResponse{}
|
||||
if err := postJSON(ctx, api.httpclient, endpoint, api.token, jsonData, response, api); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !response.Ok {
|
||||
return response.Err()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetInitialOptionFromWorkflowStepInput(selection *SelectBlockElement, inputs *WorkflowStepInputs, options []*OptionBlockObject) (*OptionBlockObject, bool) {
|
||||
if len(*inputs) == 0 {
|
||||
return &OptionBlockObject{}, false
|
||||
}
|
||||
if len(options) == 0 {
|
||||
return &OptionBlockObject{}, false
|
||||
}
|
||||
|
||||
if val, ok := (*inputs)[selection.ActionID]; ok {
|
||||
if val.SkipVariableReplacement {
|
||||
return &OptionBlockObject{}, false
|
||||
}
|
||||
|
||||
for _, option := range options {
|
||||
if option.Value == val.Value {
|
||||
return option, true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &OptionBlockObject{}, false
|
||||
}
|
Reference in New Issue
Block a user