Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1477141

Browse files
committed
Merge branch 'update-slack-library-to-0-14' into 'master'
chore: update Slack library to v0.14 See merge request postgres-ai/joe!190
2 parents f31980e + 4ad4588 commit 1477141

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

‎go.mod‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ require (
1616
github.com/rs/xid v1.2.1
1717
github.com/sergi/go-diff v1.1.0
1818
github.com/sethvargo/go-password v0.2.0
19-
github.com/slack-go/slack v0.9.2
19+
github.com/slack-go/slack v0.14.0
2020
github.com/stretchr/testify v1.7.0
2121
gitlab.com/postgres-ai/database-lab/v2 v2.4.0
22-
gopkg.in/yaml.v2 v2.4.0
2322
)
2423

2524
require (
@@ -37,7 +36,7 @@ require (
3736
github.com/go-ole/go-ole v1.2.4 // indirect
3837
github.com/gogo/protobuf v1.3.2 // indirect
3938
github.com/golang/protobuf v1.4.3 // indirect
40-
github.com/gorilla/websocket v1.4.2 // indirect
39+
github.com/gorilla/websocket v1.5.3 // indirect
4140
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
4241
github.com/jackc/pgio v1.0.0 // indirect
4342
github.com/jackc/pgpassfile v1.0.0 // indirect
@@ -62,6 +61,7 @@ require (
6261
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a // indirect
6362
google.golang.org/grpc v1.38.0 // indirect
6463
google.golang.org/protobuf v1.25.0 // indirect
64+
gopkg.in/yaml.v2 v2.4.0 // indirect
6565
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
6666
olympos.io/encoding/edn v0.0.0-20200308123125-93e3b8dd0e24 // indirect
6767
)

‎go.sum‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,9 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
345345
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
346346
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
347347
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
348-
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
349348
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
349+
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
350+
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
350351
github.com/google/go-github/v34 v34.0.0/go.mod h1:w/2qlrXUfty+lbyO6tatnzIw97v1CM+/jZcwXMDiPQQ=
351352
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
352353
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@@ -374,8 +375,9 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
374375
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
375376
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
376377
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
377-
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
378378
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
379+
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
380+
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
379381
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
380382
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
381383
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
@@ -653,8 +655,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
653655
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
654656
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
655657
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
656-
github.com/slack-go/slack v0.9.2 h1:tjIrKKYUCOmWeEAktWShKW+3UjLTH/wmgmCkAGAf8wM=
657-
github.com/slack-go/slack v0.9.2/go.mod h1:wWL//kk0ho+FcQXcBTmEafUI5dz4qz5f4mMk8oIkioQ=
658+
github.com/slack-go/slack v0.14.0 h1:6c0UTfbRnvRssZUsZ2qe0Iu07VAMPjRqOa6oX8ewF4k=
659+
github.com/slack-go/slack v0.14.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
658660
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
659661
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
660662
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=

‎pkg/connection/slack/messenger.go‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,20 +212,25 @@ func (m *Messenger) uploadFile(title string, content string, channel string, ts
212212
name := strings.ToLower(strings.ReplaceAll(title, " ", "-"))
213213
filename := fmt.Sprintf("%s.%s", name, fileType)
214214

215-
params := slack.FileUploadParameters{
215+
params := slack.UploadFileV2Parameters{
216216
Title: title,
217-
Filetype: "text",
217+
FileSize: len(content),
218218
Filename: filename,
219219
Content: content,
220-
Channels: []string{channel},
220+
Channel: channel,
221221
ThreadTimestamp: ts,
222222
}
223223

224-
file, err := m.api.UploadFile(params)
224+
fileSummary, err := m.api.UploadFileV2(params)
225225
if err != nil {
226226
return nil, errors.Wrap(err, "failed to upload a file")
227227
}
228228

229+
file, _, _, err := m.api.GetFileInfo(fileSummary.ID, 0, 0)
230+
if err != nil {
231+
return nil, errors.Wrap(err, "failed to get an uploaded file info")
232+
}
233+
229234
return file, nil
230235
}
231236

‎pkg/connection/slackrtm/messenger.go‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import (
1111
"strings"
1212
"time"
1313

14-
"github.com/pkg/errors"
15-
"github.com/slack-go/slack"
16-
1714
"gitlab.com/postgres-ai/database-lab/v2/pkg/log"
1815

1916
"gitlab.com/postgres-ai/joe/pkg/models"
17+
18+
"github.com/pkg/errors"
19+
"github.com/slack-go/slack"
2020
)
2121

2222
const errorNotPublished = "Message not published yet"
@@ -207,20 +207,25 @@ func (m *Messenger) uploadFile(title string, content string, channel string, ts
207207
name := strings.ToLower(strings.ReplaceAll(title, " ", "-"))
208208
filename := fmt.Sprintf("%s.%s", name, fileType)
209209

210-
params := slack.FileUploadParameters{
210+
params := slack.UploadFileV2Parameters{
211211
Title: title,
212-
Filetype: "text",
213212
Filename: filename,
213+
FileSize: len(content),
214214
Content: content,
215-
Channels: []string{channel},
215+
Channel: channel,
216216
ThreadTimestamp: ts,
217217
}
218218

219-
file, err := m.rtm.UploadFile(params)
219+
fileSummary, err := m.rtm.UploadFileV2(params)
220220
if err != nil {
221221
return nil, errors.Wrap(err, "failed to upload a file")
222222
}
223223

224+
file, _, _, err := m.rtm.GetFileInfo(fileSummary.ID, 0, 0)
225+
if err != nil {
226+
return nil, errors.Wrap(err, "failed to get an uploaded file info")
227+
}
228+
224229
return file, nil
225230
}
226231

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /