summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-10-19 23:40:00 +0200
committerGitHub <noreply@github.com>2020-10-19 23:40:00 +0200
commit075a84427f6332aab707d283ad770d69f8816032 (patch)
tree0ff9f56a057919f3fe968e57f6f0b1c0d1f85078 /vendor/github.com/slack-go/slack
parent950f2759bd2b20aa0bdedc3dc9a74d0dafb606d8 (diff)
downloadmatterbridge-msglm-075a84427f6332aab707d283ad770d69f8816032.tar.gz
matterbridge-msglm-075a84427f6332aab707d283ad770d69f8816032.tar.bz2
matterbridge-msglm-075a84427f6332aab707d283ad770d69f8816032.zip
Update vendor (#1265)
Diffstat (limited to 'vendor/github.com/slack-go/slack')
-rw-r--r--vendor/github.com/slack-go/slack/apps.go43
-rw-r--r--vendor/github.com/slack-go/slack/dialog.go4
-rw-r--r--vendor/github.com/slack-go/slack/interactions.go59
-rw-r--r--vendor/github.com/slack-go/slack/reminders.go30
-rw-r--r--vendor/github.com/slack-go/slack/slack.go16
-rw-r--r--vendor/github.com/slack-go/slack/slash.go2
6 files changed, 148 insertions, 6 deletions
diff --git a/vendor/github.com/slack-go/slack/apps.go b/vendor/github.com/slack-go/slack/apps.go
new file mode 100644
index 00000000..cb26ad8e
--- /dev/null
+++ b/vendor/github.com/slack-go/slack/apps.go
@@ -0,0 +1,43 @@
+package slack
+
+import (
+ "context"
+ "encoding/json"
+)
+
+type listEventAuthorizationsResponse struct {
+ SlackResponse
+ Authorizations []EventAuthorization `json:"authorizations"`
+}
+
+type EventAuthorization struct {
+ EnterpriseID string `json:"enterprise_id"`
+ TeamID string `json:"team_id"`
+ UserID string `json:"user_id"`
+ IsBot bool `json:"is_bot"`
+ IsEnterpriseInstall bool `json:"is_enterprise_install"`
+}
+
+func (api *Client) ListEventAuthorizations(eventContext string) ([]EventAuthorization, error) {
+ return api.ListEventAuthorizationsContext(context.Background(), eventContext)
+}
+
+// ListEventAuthorizationsContext lists authed users and teams for the given event_context. You must provide an app-level token to the client using OptionAppLevelToken. More info: https://api.slack.com/methods/apps.event.authorizations.list
+func (api *Client) ListEventAuthorizationsContext(ctx context.Context, eventContext string) ([]EventAuthorization, error) {
+ resp := &listEventAuthorizationsResponse{}
+
+ request, _ := json.Marshal(map[string]string{
+ "event_context": eventContext,
+ })
+
+ err := postJSON(ctx, api.httpclient, api.endpoint+"apps.event.authorizations.list", api.appLevelToken, request, &resp, api)
+
+ if err != nil {
+ return nil, err
+ }
+ if !resp.Ok {
+ return nil, resp.Err()
+ }
+
+ return resp.Authorizations, nil
+}
diff --git a/vendor/github.com/slack-go/slack/dialog.go b/vendor/github.com/slack-go/slack/dialog.go
index 376cd9e6..f94113f4 100644
--- a/vendor/github.com/slack-go/slack/dialog.go
+++ b/vendor/github.com/slack-go/slack/dialog.go
@@ -54,7 +54,9 @@ type DialogCallback InteractionCallback
// DialogSubmissionCallback is sent from Slack when a user submits a form from within a dialog
type DialogSubmissionCallback struct {
- State string `json:"state,omitempty"`
+ // NOTE: State is only used with the dialog_submission type.
+ // You should use InteractionCallback.BlockActionsState for block_actions type.
+ State string `json:"-"`
Submission map[string]string `json:"submission"`
}
diff --git a/vendor/github.com/slack-go/slack/interactions.go b/vendor/github.com/slack-go/slack/interactions.go
index c7f59217..2515e290 100644
--- a/vendor/github.com/slack-go/slack/interactions.go
+++ b/vendor/github.com/slack-go/slack/interactions.go
@@ -56,6 +56,65 @@ type InteractionCallback struct {
DialogSubmissionCallback
ViewSubmissionCallback
ViewClosedCallback
+
+ // FIXME(kanata2): just workaround for backward-compatibility.
+ // See also https://github.com/slack-go/slack/issues/816
+ RawState json.RawMessage `json:"state,omitempty"`
+
+ // BlockActionState stands for the `state` field in block_actions type.
+ // NOTE: InteractionCallback.State has a role for the state of dialog_submission type,
+ // so we cannot use this field for backward-compatibility for now.
+ BlockActionState *BlockActionStates `json:"-"`
+}
+
+type BlockActionStates struct {
+ Values map[string]map[string]BlockAction `json:"values"`
+}
+
+func (ic *InteractionCallback) MarshalJSON() ([]byte, error) {
+ type alias InteractionCallback
+ tmp := alias(*ic)
+ if tmp.Type == InteractionTypeBlockActions {
+ if tmp.BlockActionState == nil {
+ tmp.RawState = []byte(`{}`)
+ } else {
+ state, err := json.Marshal(tmp.BlockActionState.Values)
+ if err != nil {
+ return nil, err
+ }
+ tmp.RawState = []byte(`{"values":` + string(state) + `}`)
+ }
+ } else if ic.Type == InteractionTypeDialogSubmission {
+ tmp.RawState = []byte(tmp.State)
+ }
+ // Use pointer for go1.7
+ return json.Marshal(&tmp)
+}
+
+func (ic *InteractionCallback) UnmarshalJSON(b []byte) error {
+ type alias InteractionCallback
+ tmp := struct {
+ Type InteractionType `json:"type"`
+ *alias
+ }{
+ alias: (*alias)(ic),
+ }
+ if err := json.Unmarshal(b, &tmp); err != nil {
+ return err
+ }
+ *ic = InteractionCallback(*tmp.alias)
+ ic.Type = tmp.Type
+ if ic.Type == InteractionTypeBlockActions {
+ if len(ic.RawState) > 0 {
+ err := json.Unmarshal(ic.RawState, &ic.BlockActionState)
+ if err != nil {
+ return err
+ }
+ }
+ } else if ic.Type == InteractionTypeDialogSubmission {
+ ic.State = string(ic.RawState)
+ }
+ return nil
}
type Container struct {
diff --git a/vendor/github.com/slack-go/slack/reminders.go b/vendor/github.com/slack-go/slack/reminders.go
index 9b905387..de1170a6 100644
--- a/vendor/github.com/slack-go/slack/reminders.go
+++ b/vendor/github.com/slack-go/slack/reminders.go
@@ -21,6 +21,11 @@ type reminderResp struct {
Reminder Reminder `json:"reminder"`
}
+type remindersResp struct {
+ SlackResponse
+ Reminders []Reminder `json:"reminders"`
+}
+
func (api *Client) doReminder(ctx context.Context, path string, values url.Values) (*Reminder, error) {
response := &reminderResp{}
if err := api.postMethod(ctx, path, values, response); err != nil {
@@ -29,6 +34,31 @@ func (api *Client) doReminder(ctx context.Context, path string, values url.Value
return &response.Reminder, response.Err()
}
+func (api *Client) doReminders(ctx context.Context, path string, values url.Values) ([]*Reminder, error) {
+ response := &remindersResp{}
+ if err := api.postMethod(ctx, path, values, response); err != nil {
+ return nil, err
+ }
+
+ // create an array of pointers to reminders
+ var reminders = make([]*Reminder, 0, len(response.Reminders))
+ for _, reminder := range response.Reminders {
+ reminders = append(reminders, &reminder)
+ }
+
+ return reminders, response.Err()
+}
+
+// ListReminders lists all the reminders created by or for the authenticated user
+//
+// See https://api.slack.com/methods/reminders.list
+func (api *Client) ListReminders() ([]*Reminder, error) {
+ values := url.Values{
+ "token": {api.token},
+ }
+ return api.doReminders(context.Background(), "reminders.list", values)
+}
+
// AddChannelReminder adds a reminder for a channel.
//
// See https://api.slack.com/methods/reminders.add (NOTE: the ability to set
diff --git a/vendor/github.com/slack-go/slack/slack.go b/vendor/github.com/slack-go/slack/slack.go
index 0972d52e..14367365 100644
--- a/vendor/github.com/slack-go/slack/slack.go
+++ b/vendor/github.com/slack-go/slack/slack.go
@@ -57,11 +57,12 @@ type authTestResponseFull struct {
type ParamOption func(*url.Values)
type Client struct {
- token string
- endpoint string
- debug bool
- log ilogger
- httpclient httpClient
+ token string
+ appLevelToken string
+ endpoint string
+ debug bool
+ log ilogger
+ httpclient httpClient
}
// Option defines an option for a Client
@@ -93,6 +94,11 @@ func OptionAPIURL(u string) func(*Client) {
return func(c *Client) { c.endpoint = u }
}
+// OptionAppLevelToken sets an app-level token for the client.
+func OptionAppLevelToken(token string) func(*Client) {
+ return func(c *Client) { c.appLevelToken = token }
+}
+
// New builds a slack client from the provided token and options.
func New(token string, options ...Option) *Client {
s := &Client{
diff --git a/vendor/github.com/slack-go/slack/slash.go b/vendor/github.com/slack-go/slack/slash.go
index f62065a2..b2c50947 100644
--- a/vendor/github.com/slack-go/slack/slash.go
+++ b/vendor/github.com/slack-go/slack/slash.go
@@ -19,6 +19,7 @@ type SlashCommand struct {
Text string `json:"text"`
ResponseURL string `json:"response_url"`
TriggerID string `json:"trigger_id"`
+ APIAppID string `json:"api_app_id"`
}
// SlashCommandParse will parse the request of the slash command
@@ -39,6 +40,7 @@ func SlashCommandParse(r *http.Request) (s SlashCommand, err error) {
s.Text = r.PostForm.Get("text")
s.ResponseURL = r.PostForm.Get("response_url")
s.TriggerID = r.PostForm.Get("trigger_id")
+ s.APIAppID = r.PostForm.Get("api_app_id")
return s, nil
}