mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-26 05:31:34 +00:00
Update slack vendor to master (#958)
This commit is contained in:
parent
173a38a374
commit
f43faf15f8
4
go.mod
4
go.mod
@ -64,8 +64,8 @@ require (
|
|||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace github.com/nlopes/slack v0.6.0 => github.com/matterbridge/slack v0.1.1-0.20191207211853-5b5f1326cdab
|
||||||
|
|
||||||
replace github.com/bwmarrin/discordgo v0.19.0 => github.com/matterbridge/discordgo v0.0.0-20191026232317-01823f4ebba4
|
replace github.com/bwmarrin/discordgo v0.19.0 => github.com/matterbridge/discordgo v0.0.0-20191026232317-01823f4ebba4
|
||||||
|
|
||||||
replace github.com/nlopes/slack v0.6.0 => github.com/matterbridge/slack v0.1.1-0.20191113220225-25f80ef0a0d1
|
|
||||||
|
|
||||||
go 1.13
|
go 1.13
|
||||||
|
4
go.sum
4
go.sum
@ -136,8 +136,8 @@ github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18 h1:fLhwXtW
|
|||||||
github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18/go.mod h1:yAjnZ34DuDyPHMPHHjOsTk/FefW4JJjoMMCGt/8uuQA=
|
github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18/go.mod h1:yAjnZ34DuDyPHMPHHjOsTk/FefW4JJjoMMCGt/8uuQA=
|
||||||
github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61 h1:R/MgM/eUyRBQx2FiH6JVmXck8PaAuKfe2M1tWIzW7nE=
|
github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61 h1:R/MgM/eUyRBQx2FiH6JVmXck8PaAuKfe2M1tWIzW7nE=
|
||||||
github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61/go.mod h1:iXGEotOvwI1R1SjLxRc+BF5rUORTMtE0iMZBT2lxqAU=
|
github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61/go.mod h1:iXGEotOvwI1R1SjLxRc+BF5rUORTMtE0iMZBT2lxqAU=
|
||||||
github.com/matterbridge/slack v0.1.1-0.20191113220225-25f80ef0a0d1 h1:wXVBLvvMFMfqnDE6aVyxScanzRP1WIErz7+fY/9dhmY=
|
github.com/matterbridge/slack v0.1.1-0.20191207211853-5b5f1326cdab h1:4eNOoF+qvyXTwmlD5PwEwPHEpYAUTh2KpEjmEZOSVyE=
|
||||||
github.com/matterbridge/slack v0.1.1-0.20191113220225-25f80ef0a0d1/go.mod h1:2uCJim0Ct2z1Uj+XQq47KCLLC1b/9UTYaZOvDtbZfK4=
|
github.com/matterbridge/slack v0.1.1-0.20191207211853-5b5f1326cdab/go.mod h1:2uCJim0Ct2z1Uj+XQq47KCLLC1b/9UTYaZOvDtbZfK4=
|
||||||
github.com/mattermost/mattermost-server v5.5.0+incompatible h1:0wcLGgYtd+YImtLDPf2AOfpBHxbU4suATx+6XKw1XbU=
|
github.com/mattermost/mattermost-server v5.5.0+incompatible h1:0wcLGgYtd+YImtLDPf2AOfpBHxbU4suATx+6XKw1XbU=
|
||||||
github.com/mattermost/mattermost-server v5.5.0+incompatible/go.mod h1:5L6MjAec+XXQwMIt791Ganu45GKsSiM+I0tLR9wUj8Y=
|
github.com/mattermost/mattermost-server v5.5.0+incompatible/go.mod h1:5L6MjAec+XXQwMIt791Ganu45GKsSiM+I0tLR9wUj8Y=
|
||||||
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
|
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
|
||||||
|
4
vendor/github.com/nlopes/slack/.travis.yml
generated
vendored
4
vendor/github.com/nlopes/slack/.travis.yml
generated
vendored
@ -28,6 +28,10 @@ matrix:
|
|||||||
script: go test -v ./...
|
script: go test -v ./...
|
||||||
- go: "1.11.x"
|
- go: "1.11.x"
|
||||||
script: go test -v -mod=vendor ./...
|
script: go test -v -mod=vendor ./...
|
||||||
|
- go: "1.12.x"
|
||||||
|
script: go test -v -mod=vendor ./...
|
||||||
|
- go: "1.13.x"
|
||||||
|
script: go test -v -mod=vendor ./...
|
||||||
- go: "tip"
|
- go: "tip"
|
||||||
script: go test -v -mod=vendor ./...
|
script: go test -v -mod=vendor ./...
|
||||||
|
|
||||||
|
6
vendor/github.com/nlopes/slack/attachments.go
generated
vendored
6
vendor/github.com/nlopes/slack/attachments.go
generated
vendored
@ -61,7 +61,7 @@ type ConfirmationField struct {
|
|||||||
// Attachment contains all the information for an attachment
|
// Attachment contains all the information for an attachment
|
||||||
type Attachment struct {
|
type Attachment struct {
|
||||||
Color string `json:"color,omitempty"`
|
Color string `json:"color,omitempty"`
|
||||||
Fallback string `json:"fallback"`
|
Fallback string `json:"fallback,omitempty"`
|
||||||
|
|
||||||
CallbackID string `json:"callback_id,omitempty"`
|
CallbackID string `json:"callback_id,omitempty"`
|
||||||
ID int `json:"id,omitempty"`
|
ID int `json:"id,omitempty"`
|
||||||
@ -75,7 +75,7 @@ type Attachment struct {
|
|||||||
Title string `json:"title,omitempty"`
|
Title string `json:"title,omitempty"`
|
||||||
TitleLink string `json:"title_link,omitempty"`
|
TitleLink string `json:"title_link,omitempty"`
|
||||||
Pretext string `json:"pretext,omitempty"`
|
Pretext string `json:"pretext,omitempty"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text,omitempty"`
|
||||||
|
|
||||||
ImageURL string `json:"image_url,omitempty"`
|
ImageURL string `json:"image_url,omitempty"`
|
||||||
ThumbURL string `json:"thumb_url,omitempty"`
|
ThumbURL string `json:"thumb_url,omitempty"`
|
||||||
@ -84,6 +84,8 @@ type Attachment struct {
|
|||||||
Actions []AttachmentAction `json:"actions,omitempty"`
|
Actions []AttachmentAction `json:"actions,omitempty"`
|
||||||
MarkdownIn []string `json:"mrkdwn_in,omitempty"`
|
MarkdownIn []string `json:"mrkdwn_in,omitempty"`
|
||||||
|
|
||||||
|
Blocks []Block `json:"blocks,omitempty"`
|
||||||
|
|
||||||
Footer string `json:"footer,omitempty"`
|
Footer string `json:"footer,omitempty"`
|
||||||
FooterIcon string `json:"footer_icon,omitempty"`
|
FooterIcon string `json:"footer_icon,omitempty"`
|
||||||
|
|
||||||
|
1
vendor/github.com/nlopes/slack/block.go
generated
vendored
1
vendor/github.com/nlopes/slack/block.go
generated
vendored
@ -37,6 +37,7 @@ type BlockAction struct {
|
|||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
ActionTs string `json:"action_ts"`
|
ActionTs string `json:"action_ts"`
|
||||||
SelectedOption OptionBlockObject `json:"selected_option"`
|
SelectedOption OptionBlockObject `json:"selected_option"`
|
||||||
|
SelectedOptions []OptionBlockObject `json:"selected_options"`
|
||||||
SelectedUser string `json:"selected_user"`
|
SelectedUser string `json:"selected_user"`
|
||||||
SelectedChannel string `json:"selected_channel"`
|
SelectedChannel string `json:"selected_channel"`
|
||||||
SelectedConversation string `json:"selected_conversation"`
|
SelectedConversation string `json:"selected_conversation"`
|
||||||
|
3
vendor/github.com/nlopes/slack/block_conv.go
generated
vendored
3
vendor/github.com/nlopes/slack/block_conv.go
generated
vendored
@ -60,6 +60,9 @@ func (b *Blocks) UnmarshalJSON(data []byte) error {
|
|||||||
block = &ImageBlock{}
|
block = &ImageBlock{}
|
||||||
case "section":
|
case "section":
|
||||||
block = &SectionBlock{}
|
block = &SectionBlock{}
|
||||||
|
case "rich_text":
|
||||||
|
// for now ignore the (complex) content of rich_text blocks until we can fully support it
|
||||||
|
continue
|
||||||
default:
|
default:
|
||||||
block = &UnknownBlock{}
|
block = &UnknownBlock{}
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/nlopes/slack/block_object.go
generated
vendored
2
vendor/github.com/nlopes/slack/block_object.go
generated
vendored
@ -178,7 +178,7 @@ func NewConfirmationBlockObject(title, text, confirm, deny *TextBlockObject) *Co
|
|||||||
type OptionBlockObject struct {
|
type OptionBlockObject struct {
|
||||||
Text *TextBlockObject `json:"text"`
|
Text *TextBlockObject `json:"text"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOptionBlockObject returns an instance of a new Option Block Element
|
// NewOptionBlockObject returns an instance of a new Option Block Element
|
||||||
|
3
vendor/github.com/nlopes/slack/bots.go
generated
vendored
3
vendor/github.com/nlopes/slack/bots.go
generated
vendored
@ -10,6 +10,9 @@ type Bot struct {
|
|||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Deleted bool `json:"deleted"`
|
Deleted bool `json:"deleted"`
|
||||||
|
UserID string `json:"user_id"`
|
||||||
|
AppID string `json:"app_id"`
|
||||||
|
Updated JSONTime `json:"updated"`
|
||||||
Icons Icons `json:"icons"`
|
Icons Icons `json:"icons"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
vendor/github.com/nlopes/slack/chat.go
generated
vendored
6
vendor/github.com/nlopes/slack/chat.go
generated
vendored
@ -228,6 +228,7 @@ type sendConfig struct {
|
|||||||
endpoint string
|
endpoint string
|
||||||
values url.Values
|
values url.Values
|
||||||
attachments []Attachment
|
attachments []Attachment
|
||||||
|
blocks Blocks
|
||||||
responseType string
|
responseType string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,6 +243,7 @@ func (t sendConfig) BuildRequest(token, channelID string) (req *http.Request, _
|
|||||||
endpoint: t.endpoint,
|
endpoint: t.endpoint,
|
||||||
values: t.values,
|
values: t.values,
|
||||||
attachments: t.attachments,
|
attachments: t.attachments,
|
||||||
|
blocks: t.blocks,
|
||||||
responseType: t.responseType,
|
responseType: t.responseType,
|
||||||
}.BuildRequest()
|
}.BuildRequest()
|
||||||
default:
|
default:
|
||||||
@ -265,6 +267,7 @@ type responseURLSender struct {
|
|||||||
endpoint string
|
endpoint string
|
||||||
values url.Values
|
values url.Values
|
||||||
attachments []Attachment
|
attachments []Attachment
|
||||||
|
blocks Blocks
|
||||||
responseType string
|
responseType string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +276,7 @@ func (t responseURLSender) BuildRequest() (*http.Request, func(*chatResponseFull
|
|||||||
Text: t.values.Get("text"),
|
Text: t.values.Get("text"),
|
||||||
Timestamp: t.values.Get("ts"),
|
Timestamp: t.values.Get("ts"),
|
||||||
Attachments: t.attachments,
|
Attachments: t.attachments,
|
||||||
|
Blocks: t.blocks,
|
||||||
ResponseType: t.responseType,
|
ResponseType: t.responseType,
|
||||||
})
|
})
|
||||||
return req, func(resp *chatResponseFull) responseParser {
|
return req, func(resp *chatResponseFull) responseParser {
|
||||||
@ -420,6 +424,8 @@ func MsgOptionBlocks(blocks ...Block) MsgOption {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.blocks.BlockSet = append(config.blocks.BlockSet, blocks...)
|
||||||
|
|
||||||
blocks, err := json.Marshal(blocks)
|
blocks, err := json.Marshal(blocks)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
config.values.Set("blocks", string(blocks))
|
config.values.Set("blocks", string(blocks))
|
||||||
|
2
vendor/github.com/nlopes/slack/errors.go
generated
vendored
2
vendor/github.com/nlopes/slack/errors.go
generated
vendored
@ -6,6 +6,8 @@ import "github.com/nlopes/slack/internal/errorsx"
|
|||||||
const (
|
const (
|
||||||
ErrAlreadyDisconnected = errorsx.String("Invalid call to Disconnect - Slack API is already disconnected")
|
ErrAlreadyDisconnected = errorsx.String("Invalid call to Disconnect - Slack API is already disconnected")
|
||||||
ErrRTMDisconnected = errorsx.String("disconnect received while trying to connect")
|
ErrRTMDisconnected = errorsx.String("disconnect received while trying to connect")
|
||||||
|
ErrRTMGoodbye = errorsx.String("goodbye detected")
|
||||||
|
ErrRTMDeadman = errorsx.String("deadman switch triggered")
|
||||||
ErrParametersMissing = errorsx.String("received empty parameters")
|
ErrParametersMissing = errorsx.String("received empty parameters")
|
||||||
ErrInvalidConfiguration = errorsx.String("invalid configuration")
|
ErrInvalidConfiguration = errorsx.String("invalid configuration")
|
||||||
ErrMissingHeaders = errorsx.String("missing headers")
|
ErrMissingHeaders = errorsx.String("missing headers")
|
||||||
|
43
vendor/github.com/nlopes/slack/interactions.go
generated
vendored
43
vendor/github.com/nlopes/slack/interactions.go
generated
vendored
@ -1,6 +1,7 @@
|
|||||||
package slack
|
package slack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -53,6 +54,48 @@ type ActionCallbacks struct {
|
|||||||
BlockActions []*BlockAction
|
BlockActions []*BlockAction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalJSON implements the Marshaller interface in order to combine both
|
||||||
|
// action callback types back into a single array, like how the api responds.
|
||||||
|
// This makes Marshaling and Unmarshaling an InteractionCallback symmetrical
|
||||||
|
func (a ActionCallbacks) MarshalJSON() ([]byte, error) {
|
||||||
|
count := 0
|
||||||
|
length := len(a.AttachmentActions) + len(a.BlockActions)
|
||||||
|
buffer := bytes.NewBufferString("[")
|
||||||
|
|
||||||
|
f := func(obj interface{}) error {
|
||||||
|
js, err := json.Marshal(obj)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = buffer.Write(js)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
count++
|
||||||
|
if count < length {
|
||||||
|
_, err = buffer.WriteString(",")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, act := range a.AttachmentActions {
|
||||||
|
err := f(act)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, blk := range a.BlockActions {
|
||||||
|
err := f(blk)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buffer.WriteString("]")
|
||||||
|
return buffer.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements the Marshaller interface in order to delegate
|
// UnmarshalJSON implements the Marshaller interface in order to delegate
|
||||||
// marshalling and allow for proper type assertion when decoding the response
|
// marshalling and allow for proper type assertion when decoding the response
|
||||||
func (a *ActionCallbacks) UnmarshalJSON(data []byte) error {
|
func (a *ActionCallbacks) UnmarshalJSON(data []byte) error {
|
||||||
|
2
vendor/github.com/nlopes/slack/messages.go
generated
vendored
2
vendor/github.com/nlopes/slack/messages.go
generated
vendored
@ -101,7 +101,7 @@ type Msg struct {
|
|||||||
const (
|
const (
|
||||||
// ResponseTypeInChannel in channel response for slash commands.
|
// ResponseTypeInChannel in channel response for slash commands.
|
||||||
ResponseTypeInChannel = "in_channel"
|
ResponseTypeInChannel = "in_channel"
|
||||||
// ResponseTypeEphemeral ephemeral respone for slash commands.
|
// ResponseTypeEphemeral ephemeral response for slash commands.
|
||||||
ResponseTypeEphemeral = "ephemeral"
|
ResponseTypeEphemeral = "ephemeral"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
2
vendor/github.com/nlopes/slack/rtm.go
generated
vendored
2
vendor/github.com/nlopes/slack/rtm.go
generated
vendored
@ -2,7 +2,6 @@ package slack
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -120,7 +119,6 @@ func (api *Client) NewRTM(options ...RTMOption) *RTM {
|
|||||||
disconnected: make(chan struct{}),
|
disconnected: make(chan struct{}),
|
||||||
disconnectedm: &sync.Once{},
|
disconnectedm: &sync.Once{},
|
||||||
forcePing: make(chan bool),
|
forcePing: make(chan bool),
|
||||||
rawEvents: make(chan json.RawMessage),
|
|
||||||
idGen: NewSafeID(1),
|
idGen: NewSafeID(1),
|
||||||
mu: &sync.Mutex{},
|
mu: &sync.Mutex{},
|
||||||
}
|
}
|
||||||
|
6
vendor/github.com/nlopes/slack/search.go
generated
vendored
6
vendor/github.com/nlopes/slack/search.go
generated
vendored
@ -25,6 +25,12 @@ type SearchParameters struct {
|
|||||||
type CtxChannel struct {
|
type CtxChannel struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
IsExtShared bool `json:"is_ext_shared"`
|
||||||
|
IsMPIM bool `json:"is_mpim"`
|
||||||
|
ISOrgShared bool `json:"is_org_shared"`
|
||||||
|
IsPendingExtShared bool `json:"is_pending_ext_shared"`
|
||||||
|
IsPrivate bool `json:"is_private"`
|
||||||
|
IsShared bool `json:"is_shared"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CtxMessage struct {
|
type CtxMessage struct {
|
||||||
|
103
vendor/github.com/nlopes/slack/stars.go
generated
vendored
103
vendor/github.com/nlopes/slack/stars.go
generated
vendored
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -158,3 +159,105 @@ func (api *Client) GetStarredContext(ctx context.Context, params StarsParameters
|
|||||||
}
|
}
|
||||||
return starredItems, paging, nil
|
return starredItems, paging, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type listResponsePaginated struct {
|
||||||
|
Items []Item `json:"items"`
|
||||||
|
SlackResponse
|
||||||
|
Metadata ResponseMetadata `json:"response_metadata"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// StarredItemPagination allows for paginating over the starred items
|
||||||
|
type StarredItemPagination struct {
|
||||||
|
Items []Item
|
||||||
|
limit int
|
||||||
|
previousResp *ResponseMetadata
|
||||||
|
c *Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStarsOption options for the GetUsers method call.
|
||||||
|
type ListStarsOption func(*StarredItemPagination)
|
||||||
|
|
||||||
|
// ListAllStars returns the complete list of starred items
|
||||||
|
func (api *Client) ListAllStars() ([]Item, error) {
|
||||||
|
return api.ListAllStarsContext(context.Background())
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAllStarsContext returns the list of users (with their detailed information) with a custom context
|
||||||
|
func (api *Client) ListAllStarsContext(ctx context.Context) (results []Item, err error) {
|
||||||
|
p := api.ListStarsPaginated()
|
||||||
|
for err == nil {
|
||||||
|
p, err = p.next(ctx)
|
||||||
|
if err == nil {
|
||||||
|
results = append(results, p.Items...)
|
||||||
|
} else if rateLimitedError, ok := err.(*RateLimitedError); ok {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
err = ctx.Err()
|
||||||
|
case <-time.After(rateLimitedError.RetryAfter):
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results, p.failure(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStarsPaginated fetches users in a paginated fashion, see ListStarsPaginationContext for usage.
|
||||||
|
func (api *Client) ListStarsPaginated(options ...ListStarsOption) StarredItemPagination {
|
||||||
|
return newStarPagination(api, options...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newStarPagination(c *Client, options ...ListStarsOption) (sip StarredItemPagination) {
|
||||||
|
sip = StarredItemPagination{
|
||||||
|
c: c,
|
||||||
|
limit: 200, // per slack api documentation.
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, opt := range options {
|
||||||
|
opt(&sip)
|
||||||
|
}
|
||||||
|
|
||||||
|
return sip
|
||||||
|
}
|
||||||
|
|
||||||
|
// done checks if the pagination has completed
|
||||||
|
func (StarredItemPagination) done(err error) bool {
|
||||||
|
return err == errPaginationComplete
|
||||||
|
}
|
||||||
|
|
||||||
|
// done checks if pagination failed.
|
||||||
|
func (t StarredItemPagination) failure(err error) error {
|
||||||
|
if t.done(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// next gets the next list of starred items based on the cursor value
|
||||||
|
func (t StarredItemPagination) next(ctx context.Context) (_ StarredItemPagination, err error) {
|
||||||
|
var (
|
||||||
|
resp *listResponsePaginated
|
||||||
|
)
|
||||||
|
|
||||||
|
if t.c == nil || (t.previousResp != nil && t.previousResp.Cursor == "") {
|
||||||
|
return t, errPaginationComplete
|
||||||
|
}
|
||||||
|
|
||||||
|
t.previousResp = t.previousResp.initialize()
|
||||||
|
|
||||||
|
values := url.Values{
|
||||||
|
"limit": {strconv.Itoa(t.limit)},
|
||||||
|
"token": {t.c.token},
|
||||||
|
"cursor": {t.previousResp.Cursor},
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = t.c.postMethod(ctx, "stars.list", values, &resp); err != nil {
|
||||||
|
return t, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t.previousResp = &resp.Metadata
|
||||||
|
t.Items = resp.Items
|
||||||
|
|
||||||
|
return t, nil
|
||||||
|
}
|
||||||
|
2
vendor/github.com/nlopes/slack/websocket.go
generated
vendored
2
vendor/github.com/nlopes/slack/websocket.go
generated
vendored
@ -1,7 +1,6 @@
|
|||||||
package slack
|
package slack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -35,7 +34,6 @@ type RTM struct {
|
|||||||
disconnected chan struct{}
|
disconnected chan struct{}
|
||||||
disconnectedm *sync.Once
|
disconnectedm *sync.Once
|
||||||
forcePing chan bool
|
forcePing chan bool
|
||||||
rawEvents chan json.RawMessage
|
|
||||||
|
|
||||||
// UserDetails upon connection
|
// UserDetails upon connection
|
||||||
info *Info
|
info *Info
|
||||||
|
19
vendor/github.com/nlopes/slack/websocket_desktop_notification.go
generated
vendored
Normal file
19
vendor/github.com/nlopes/slack/websocket_desktop_notification.go
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package slack
|
||||||
|
|
||||||
|
// DesktopNotificationEvent represents the update event for Desktop Notification.
|
||||||
|
type DesktopNotificationEvent struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Subtitle string `json:"subtitle"`
|
||||||
|
Message string `json:"msg"`
|
||||||
|
Timestamp string `json:"ts"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
Channel string `json:"channel"`
|
||||||
|
LaunchURI string `json:"launchUri"`
|
||||||
|
AvatarImage string `json:"avatarImage"`
|
||||||
|
SsbFilename string `json:"ssbFilename"`
|
||||||
|
ImageURI string `json:"imageUri"`
|
||||||
|
IsShared bool `json:"is_shared"`
|
||||||
|
IsChannelInvite bool `json:"is_channel_invite"`
|
||||||
|
EventTimestamp string `json:"event_ts"`
|
||||||
|
}
|
61
vendor/github.com/nlopes/slack/websocket_managed_conn.go
generated
vendored
61
vendor/github.com/nlopes/slack/websocket_managed_conn.go
generated
vendored
@ -58,15 +58,19 @@ func (rtm *RTM) ManageConnection() {
|
|||||||
|
|
||||||
rtm.Debugf("RTM connection succeeded on try %d", connectionCount)
|
rtm.Debugf("RTM connection succeeded on try %d", connectionCount)
|
||||||
|
|
||||||
|
rawEvents := make(chan json.RawMessage)
|
||||||
// we're now connected so we can set up listeners
|
// we're now connected so we can set up listeners
|
||||||
go rtm.handleIncomingEvents()
|
go rtm.handleIncomingEvents(rawEvents)
|
||||||
|
|
||||||
// this should be a blocking call until the connection has ended
|
// this should be a blocking call until the connection has ended
|
||||||
rtm.handleEvents()
|
rtm.handleEvents(rawEvents)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-rtm.disconnected:
|
case <-rtm.disconnected:
|
||||||
// after handle events returns we need to check if we're disconnected
|
// after handle events returns we need to check if we're disconnected
|
||||||
|
// when this happens we need to cleanup the newly created connection.
|
||||||
|
if err = conn.Close(); err != nil {
|
||||||
|
rtm.Debugln("failed to close conn on disconnected RTM", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
// otherwise continue and run the loop again to reconnect
|
// otherwise continue and run the loop again to reconnect
|
||||||
@ -208,7 +212,7 @@ func (rtm *RTM) startRTMAndDial(useRTMStart bool) (info *Info, _ *websocket.Conn
|
|||||||
// This should not be called directly! Instead a boolean value (true for
|
// This should not be called directly! Instead a boolean value (true for
|
||||||
// intentional, false otherwise) should be sent to the killChannel on the RTM.
|
// intentional, false otherwise) should be sent to the killChannel on the RTM.
|
||||||
func (rtm *RTM) killConnection(intentional bool, cause error) (err error) {
|
func (rtm *RTM) killConnection(intentional bool, cause error) (err error) {
|
||||||
rtm.Debugln("killing connection")
|
rtm.Debugln("killing connection", cause)
|
||||||
|
|
||||||
if rtm.conn != nil {
|
if rtm.conn != nil {
|
||||||
err = rtm.conn.Close()
|
err = rtm.conn.Close()
|
||||||
@ -228,7 +232,7 @@ func (rtm *RTM) killConnection(intentional bool, cause error) (err error) {
|
|||||||
// interval. This also sends outgoing messages that are received from the RTM's
|
// interval. This also sends outgoing messages that are received from the RTM's
|
||||||
// outgoingMessages channel. This also handles incoming raw events from the RTM
|
// outgoingMessages channel. This also handles incoming raw events from the RTM
|
||||||
// rawEvents channel.
|
// rawEvents channel.
|
||||||
func (rtm *RTM) handleEvents() {
|
func (rtm *RTM) handleEvents(events chan json.RawMessage) {
|
||||||
ticker := time.NewTicker(rtm.pingInterval)
|
ticker := time.NewTicker(rtm.pingInterval)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
@ -239,7 +243,7 @@ func (rtm *RTM) handleEvents() {
|
|||||||
return
|
return
|
||||||
// detect when the connection is dead.
|
// detect when the connection is dead.
|
||||||
case <-rtm.pingDeadman.C:
|
case <-rtm.pingDeadman.C:
|
||||||
_ = rtm.killConnection(false, errorsx.String("deadman switch triggered"))
|
_ = rtm.killConnection(false, ErrRTMDeadman)
|
||||||
return
|
return
|
||||||
// send pings on ticker interval
|
// send pings on ticker interval
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
@ -256,11 +260,16 @@ func (rtm *RTM) handleEvents() {
|
|||||||
case msg := <-rtm.outgoingMessages:
|
case msg := <-rtm.outgoingMessages:
|
||||||
rtm.sendOutgoingMessage(msg)
|
rtm.sendOutgoingMessage(msg)
|
||||||
// listen for incoming messages that need to be parsed
|
// listen for incoming messages that need to be parsed
|
||||||
case rawEvent := <-rtm.rawEvents:
|
case rawEvent := <-events:
|
||||||
switch rtm.handleRawEvent(rawEvent) {
|
switch rtm.handleRawEvent(rawEvent) {
|
||||||
case rtmEventTypeGoodbye:
|
case rtmEventTypeGoodbye:
|
||||||
_ = rtm.killConnection(false, errorsx.String("goodbye detected"))
|
// kill the connection, but DO NOT RETURN, a follow up kill signal will
|
||||||
return
|
// be sent that still needs to be processed. this duplication is because
|
||||||
|
// the event reader restarts once it emits the goodbye event.
|
||||||
|
// unlike the other cases in this function a final read will be triggered
|
||||||
|
// against the connection which will emit a kill signal. if we return early
|
||||||
|
// this kill signal will be processed by the next connection.
|
||||||
|
_ = rtm.killConnection(false, ErrRTMGoodbye)
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -268,13 +277,17 @@ func (rtm *RTM) handleEvents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handleIncomingEvents monitors the RTM's opened websocket for any incoming
|
// handleIncomingEvents monitors the RTM's opened websocket for any incoming
|
||||||
// events. It pushes the raw events onto the RTM channel rawEvents.
|
// events. It pushes the raw events into the channel.
|
||||||
//
|
//
|
||||||
// This will stop executing once the RTM's keepRunning channel has been closed
|
// This will stop executing once the RTM's when a fatal error is detected, or
|
||||||
// or has anything sent to it.
|
// a disconnect occurs.
|
||||||
func (rtm *RTM) handleIncomingEvents() {
|
func (rtm *RTM) handleIncomingEvents(events chan json.RawMessage) {
|
||||||
for {
|
for {
|
||||||
if err := rtm.receiveIncomingEvent(); err != nil {
|
if err := rtm.receiveIncomingEvent(events); err != nil {
|
||||||
|
select {
|
||||||
|
case rtm.killChannel <- false:
|
||||||
|
case <-rtm.disconnected:
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,9 +349,15 @@ func (rtm *RTM) ping() error {
|
|||||||
// receiveIncomingEvent attempts to receive an event from the RTM's websocket.
|
// receiveIncomingEvent attempts to receive an event from the RTM's websocket.
|
||||||
// This will block until a frame is available from the websocket.
|
// This will block until a frame is available from the websocket.
|
||||||
// If the read from the websocket results in a fatal error, this function will return non-nil.
|
// If the read from the websocket results in a fatal error, this function will return non-nil.
|
||||||
func (rtm *RTM) receiveIncomingEvent() error {
|
func (rtm *RTM) receiveIncomingEvent(events chan json.RawMessage) error {
|
||||||
event := json.RawMessage{}
|
event := json.RawMessage{}
|
||||||
err := rtm.conn.ReadJSON(&event)
|
err := rtm.conn.ReadJSON(&event)
|
||||||
|
|
||||||
|
// check if the connection was closed.
|
||||||
|
if websocket.IsUnexpectedCloseError(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case err == io.ErrUnexpectedEOF:
|
case err == io.ErrUnexpectedEOF:
|
||||||
// EOF's don't seem to signify a failed connection so instead we ignore
|
// EOF's don't seem to signify a failed connection so instead we ignore
|
||||||
@ -357,22 +376,18 @@ func (rtm *RTM) receiveIncomingEvent() error {
|
|||||||
ErrorObj: err,
|
ErrorObj: err,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
select {
|
|
||||||
case rtm.killChannel <- false:
|
|
||||||
case <-rtm.disconnected:
|
|
||||||
}
|
|
||||||
|
|
||||||
return err
|
return err
|
||||||
case len(event) == 0:
|
case len(event) == 0:
|
||||||
rtm.Debugln("Received empty event")
|
rtm.Debugln("Received empty event")
|
||||||
default:
|
default:
|
||||||
rtm.Debugln("Incoming Event:", string(event))
|
rtm.Debugln("Incoming Event:", string(event))
|
||||||
select {
|
select {
|
||||||
case rtm.rawEvents <- event:
|
case events <- event:
|
||||||
case <-rtm.disconnected:
|
case <-rtm.disconnected:
|
||||||
rtm.Debugln("disonnected while attempting to send raw event")
|
rtm.Debugln("disonnected while attempting to send raw event")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,8 +411,6 @@ func (rtm *RTM) handleRawEvent(rawEvent json.RawMessage) string {
|
|||||||
rtm.handlePong(rawEvent)
|
rtm.handlePong(rawEvent)
|
||||||
case rtmEventTypeGoodbye:
|
case rtmEventTypeGoodbye:
|
||||||
// just return the event type up for goodbye, will be handled by caller.
|
// just return the event type up for goodbye, will be handled by caller.
|
||||||
case rtmEventTypeDesktopNotification:
|
|
||||||
rtm.Debugln("Received desktop notification, ignoring")
|
|
||||||
default:
|
default:
|
||||||
rtm.handleEvent(event.Type, rawEvent)
|
rtm.handleEvent(event.Type, rawEvent)
|
||||||
}
|
}
|
||||||
@ -563,4 +576,6 @@ var EventMapping = map[string]interface{}{
|
|||||||
"subteam_self_added": SubteamSelfAddedEvent{},
|
"subteam_self_added": SubteamSelfAddedEvent{},
|
||||||
"subteam_self_removed": SubteamSelfRemovedEvent{},
|
"subteam_self_removed": SubteamSelfRemovedEvent{},
|
||||||
"subteam_updated": SubteamUpdatedEvent{},
|
"subteam_updated": SubteamUpdatedEvent{},
|
||||||
|
|
||||||
|
"desktop_notification": DesktopNotificationEvent{},
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/nlopes/slack/websocket_misc.go
generated
vendored
2
vendor/github.com/nlopes/slack/websocket_misc.go
generated
vendored
@ -131,7 +131,7 @@ type MemberJoinedChannelEvent struct {
|
|||||||
Inviter string `json:"inviter"`
|
Inviter string `json:"inviter"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MemberJoinedChannelEvent, a user left a public or private channel
|
// MemberLeftChannelEvent a user left a public or private channel
|
||||||
type MemberLeftChannelEvent struct {
|
type MemberLeftChannelEvent struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -138,7 +138,7 @@ github.com/nicksnyder/go-i18n/i18n
|
|||||||
github.com/nicksnyder/go-i18n/i18n/bundle
|
github.com/nicksnyder/go-i18n/i18n/bundle
|
||||||
github.com/nicksnyder/go-i18n/i18n/language
|
github.com/nicksnyder/go-i18n/i18n/language
|
||||||
github.com/nicksnyder/go-i18n/i18n/translation
|
github.com/nicksnyder/go-i18n/i18n/translation
|
||||||
# github.com/nlopes/slack v0.6.0 => github.com/matterbridge/slack v0.1.1-0.20191113220225-25f80ef0a0d1
|
# github.com/nlopes/slack v0.6.0 => github.com/matterbridge/slack v0.1.1-0.20191207211853-5b5f1326cdab
|
||||||
github.com/nlopes/slack
|
github.com/nlopes/slack
|
||||||
github.com/nlopes/slack/internal/errorsx
|
github.com/nlopes/slack/internal/errorsx
|
||||||
github.com/nlopes/slack/internal/timex
|
github.com/nlopes/slack/internal/timex
|
||||||
|
Loading…
Reference in New Issue
Block a user