Skip to content

Commit

Permalink
Merge pull request #179 from rusq/update-slack-lib
Browse files Browse the repository at this point in the history
update slack lib to v0.12.0 (clone)
  • Loading branch information
rusq authored Jan 24, 2023
2 parents b5c924f + dc0cafa commit be138f4
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 14 deletions.
8 changes: 4 additions & 4 deletions clienter_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (se *Export) inclusiveExport(ctx context.Context, uidx structures.UserIndex
if err != nil {
return nil, err
}
ch, err := se.sd.Client().GetConversationInfoContext(ctx, sl.Channel, true)
ch, err := se.sd.Client().GetConversationInfoContext(ctx, &slack.GetConversationInfoInput{ChannelID: sl.Channel, IncludeLocale: true, IncludeNumMembers: true})
if err != nil {
return nil, fmt.Errorf("error getting info for %s: %w", sl, err)
}
Expand Down
2 changes: 1 addition & 1 deletion export/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func newExportMessage(msg *types.Message, users structures.UserIndex) *ExportMes

if user, ok := users[msg.User]; ok && !user.IsBot {
expMsg.UserProfile = &ExportUserProfile{
AvatarHash: user.Profile.AvatarHash, // is currently not populated.
AvatarHash: "",
Image72: user.Profile.Image72,
FirstName: user.Profile.FirstName,
RealName: user.Profile.RealName,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/slack-go/slack => github.com/rusq/slack v0.11.300
replace github.com/slack-go/slack => github.com/rusq/slack v0.12.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ github.com/rusq/secure v0.0.3 h1:PcWc7devLyJfMk8KZW2qUQFwhH5ugme4ncbcGztsLPw=
github.com/rusq/secure v0.0.3/go.mod h1:F1QilMKreuFRjov0UY7DZSIXn77/8RqMVGu2zV0RtqY=
github.com/rusq/secure v0.0.4 h1:svpiZHfHnx89eEDCCFI9OXG1Y8hL9kUWUG6fJbrWUOI=
github.com/rusq/secure v0.0.4/go.mod h1:F1QilMKreuFRjov0UY7DZSIXn77/8RqMVGu2zV0RtqY=
github.com/rusq/slack v0.11.300 h1:s/1gVdKU+gD+3DUhAzMV6NwBGSUOP65J7QP0pB6EZRQ=
github.com/rusq/slack v0.11.300/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
github.com/rusq/slack v0.12.0 h1:/LTTLPAoZU7Epvd11i+/OHJfHTac33jfnlqiH7jlVuM=
github.com/rusq/slack v0.12.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
github.com/rusq/tracer v1.0.1 h1:5u4PCV8NGO97VuAINQA4gOVRkPoqHimLE2jpezRVNMU=
github.com/rusq/tracer v1.0.1/go.mod h1:Rqu48C3/K8bA5NPmF20Hft73v431MQIdM+Co+113pME=
github.com/schollz/progressbar/v3 v3.8.6 h1:QruMUdzZ1TbEP++S1m73OqRJk20ON11m6Wqv4EoGg8c=
Expand Down
2 changes: 1 addition & 1 deletion messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (sd *Session) getChannelName(ctx context.Context, l *rate.Limiter, channelI
var ci *slack.Channel
if err := withRetry(ctx, l, sd.options.Tier3Retries, func() error {
var err error
ci, err = sd.client.GetConversationInfoContext(ctx, channelID, false)
ci, err = sd.client.GetConversationInfoContext(ctx, &slack.GetConversationInfoInput{ChannelID: channelID})
return err
}); err != nil {
return "", err
Expand Down
12 changes: 9 additions & 3 deletions messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ func TestSession_DumpAll(t *testing.T) {
}

func mockConvInfo(mc *mockClienter, channelID, wantName string) {
mc.EXPECT().GetConversationInfoContext(gomock.Any(), channelID, false).Return(&slack.Channel{GroupConversation: slack.GroupConversation{Name: wantName, Conversation: slack.Conversation{NameNormalized: wantName + "_normalized"}}}, nil)
mc.EXPECT().
GetConversationInfoContext(gomock.Any(), &slack.GetConversationInfoInput{ChannelID: channelID}).
Return(&slack.Channel{GroupConversation: slack.GroupConversation{Name: wantName, Conversation: slack.Conversation{NameNormalized: wantName + "_normalized"}}}, nil)
}

func TestConversation_String(t *testing.T) {
Expand Down Expand Up @@ -389,7 +391,9 @@ func TestSession_getChannelName(t *testing.T) {
channelID: "TESTCHAN",
},
expectFn: func(sc *mockClienter) {
sc.EXPECT().GetConversationInfoContext(gomock.Any(), "TESTCHAN", false).Return(&slack.Channel{GroupConversation: slack.GroupConversation{Name: "unittest", Conversation: slack.Conversation{NameNormalized: "unittest_normalized"}}}, nil)
sc.EXPECT().
GetConversationInfoContext(gomock.Any(), &slack.GetConversationInfoInput{ChannelID: "TESTCHAN"}).
Return(&slack.Channel{GroupConversation: slack.GroupConversation{Name: "unittest", Conversation: slack.Conversation{NameNormalized: "unittest_normalized"}}}, nil)
},
want: "unittest",
wantErr: false,
Expand All @@ -403,7 +407,9 @@ func TestSession_getChannelName(t *testing.T) {
channelID: "TESTCHAN",
},
expectFn: func(sc *mockClienter) {
sc.EXPECT().GetConversationInfoContext(gomock.Any(), "TESTCHAN", false).Return(nil, errors.New("rekt"))
sc.EXPECT().
GetConversationInfoContext(gomock.Any(), &slack.GetConversationInfoInput{ChannelID: "TESTCHAN"}).
Return(nil, errors.New("rekt"))
},
want: "",
wantErr: true,
Expand Down
115 changes: 115 additions & 0 deletions mocks/mock_io/mock_io.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion slackdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Session struct {
// clienter is the interface with some functions of slack.Client with the sole
// purpose of mocking in tests (see client_mock.go)
type clienter interface {
GetConversationInfoContext(ctx context.Context, channelID string, includeLocale bool) (*slack.Channel, error)
GetConversationInfoContext(ctx context.Context, input *slack.GetConversationInfoInput) (*slack.Channel, error)
GetConversationHistoryContext(ctx context.Context, params *slack.GetConversationHistoryParameters) (*slack.GetConversationHistoryResponse, error)
GetConversationRepliesContext(ctx context.Context, params *slack.GetConversationRepliesParameters) (msgs []slack.Message, hasMore bool, nextCursor string, err error)
GetConversationsContext(ctx context.Context, params *slack.GetConversationsParameters) (channels []slack.Channel, nextCursor string, err error)
Expand Down

0 comments on commit be138f4

Please sign in to comment.