Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESP-4311 Mostly update forked slack go library #34

Merged
Show file tree
Hide file tree
Changes from 181 commits
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
b54bd85
Add example of updating modal
KouWakai Dec 13, 2022
32bb00d
socketmode.Client.run: Fix #1125 by allowing producer of channel to c…
iaburton Dec 20, 2022
c6ed812
socketmode.Client.run: Fix small race potential on 'firstErr' as the …
iaburton Dec 20, 2022
0254b8f
socketmode.Client.Events: Change all events produced to Events channe…
iaburton Dec 20, 2022
25f2f6e
socketmode.Client.run: Cover edge case where all goroutines exit nil,…
iaburton Dec 20, 2022
bb28237
socketmode: Slight refactor of Send/Ack on Client to allow passing co…
iaburton Dec 20, 2022
377ffe4
socketmode: Shore up error handling via errors.Is/As/(Un)Wrapping, ot…
iaburton Dec 20, 2022
7589264
delete dupulicated code at L181
KouWakai Dec 25, 2022
c4f3ebe
Change comments at L183 to suggestion
KouWakai Dec 25, 2022
824342e
Change http response StatusUnauthorized at L188 to StatusInternalServ…
KouWakai Dec 25, 2022
ff7c502
socketmode example: use embedded api client in socketmode client
kittydoor Feb 5, 2023
2c07018
socketmode remove duplicate debug logging
kittydoor Feb 5, 2023
d66f160
socketmode bytes no longer used
kittydoor Feb 5, 2023
3d08e57
socketmodehandler: implemented RunEventLoopContext method. now socket…
Feb 15, 2023
dc96c95
socketmode: awaiting of message receiver goroutine in run method to a…
lololozhkin Feb 15, 2023
39c076e
bugfix: silly mistake in runLoop method, renamed closed to ok (recv c…
lololozhkin Feb 17, 2023
c13750f
Export the Binder type from slacktest
kpaulisse Feb 27, 2023
63294cb
Add ReplyUsers to Msg Struct
aleksa11010 Mar 6, 2023
b870f29
add support for user_profile_changed callback event
Mar 16, 2023
f63770d
add test
Mar 16, 2023
5380d7d
add 2FA type to slack user
imilchev Mar 24, 2023
a22a95b
Remove omitempty
kanata2 Mar 28, 2023
22489e7
Test with Go 1.18~1.20
kanata2 Mar 28, 2023
5923d7d
Merge pull request #1183 from imilchev/user-2fa-type
kanata2 Mar 28, 2023
2c348c8
Merge pull request #1186 from slack-go/use-latest-3-versions-in-ci
kanata2 Mar 28, 2023
e2fef23
Merge pull request #1182 from verygoodsoftwarenotvirus/master
kanata2 Mar 28, 2023
c041414
Update README for slacktest
kanata2 Mar 28, 2023
21cbc5f
Merge pull request #1187 from slack-go/license-readme
kanata2 Mar 28, 2023
c8507df
Merge pull request #1177 from kpaulisse/kpaulisse-binder
kanata2 Mar 28, 2023
92a834b
Add actions/stale action
kanata2 Apr 5, 2023
7f26ad5
Merge pull request #1188 from slack-go/add-stale-action
kanata2 Apr 5, 2023
b146c45
Increase operations-per-run
kanata2 Apr 5, 2023
002a1c6
Merge pull request #1189 from slack-go/increase-operations-per-run
kanata2 Apr 5, 2023
b4b5a64
Merge pull request #1165 from kittydoor/socketmode-remove-duplicate-d…
kanata2 Apr 6, 2023
d5e621e
Bump up golangci-lint and its action to latest
kanata2 Apr 13, 2023
39c7b2a
Add git repository's checkout option
kanata2 Apr 13, 2023
54fa87e
Add setup-go step
kanata2 Apr 13, 2023
7f50a78
Merge pull request #1193 from slack-go/update-linter
kanata2 Apr 13, 2023
5281ebe
Merge pull request #1169 from lololozhkin/socketmode-runEventLoopContext
kanata2 Apr 13, 2023
58c5a5f
Merge pull request #1180 from aleksa11010/patch-1
kanata2 Apr 13, 2023
2b2e893
gofmt
kanata2 Apr 13, 2023
646e50d
Merge pull request #1194 from slack-go/fix-lintter-error
kanata2 Apr 13, 2023
f2673af
Merge pull request #1170 from lololozhkin/socketmode-ResolvePanicOnRe…
kanata2 Apr 15, 2023
c4095cb
Merge pull request #1164 from kittydoor/socketmode-example
kanata2 Apr 15, 2023
8c8b886
Merge remote-tracking branch 'upstream/master' into safer-socketmode
iaburton Apr 24, 2023
5babfb7
Add 'FIXME's for deadman timer reset race
iaburton Apr 24, 2023
4dd1a1f
Fix race on deadman timer Elapsed+Reset by more efficient use of tick…
iaburton Apr 24, 2023
2680267
Add UnfurlLinks and UnfurlMedia to WebhookMessage
Jun 22, 2023
7302609
chore: unnecessary use of fmt.Sprintf
testwill Jul 10, 2023
e54a868
Redact tokens in debug log
daabr Jul 14, 2023
05af10c
Tiny unrelated lint fix
daabr Jul 14, 2023
fcee000
Add support for refresh tokens
daabr Jul 16, 2023
db60a05
Conversation inviteShared support
nopcoder Jul 16, 2023
f7c27ea
Create structs for manifest endpoint
stijndcl Aug 3, 2023
00233ed
Add requests to validate manifests
stijndcl Aug 3, 2023
3b8d5b7
Add create and delete methods, implement common interface
stijndcl Aug 4, 2023
7fceb91
Add tokens
stijndcl Aug 4, 2023
4b09d41
Finish manifest methods
stijndcl Aug 4, 2023
1abbd7a
Fix linting
stijndcl Aug 4, 2023
6c46b7c
Rename value
stijndcl Aug 4, 2023
dd3d9cc
More tests, return manifest itself when exporting
stijndcl Aug 4, 2023
6bfd393
Undo pointer and take reference manually
stijndcl Aug 4, 2023
c33746b
More tests
stijndcl Aug 4, 2023
f7d479f
Add options for tokens
stijndcl Aug 4, 2023
14d4607
Use correct method
stijndcl Aug 4, 2023
a33e5ae
use config token
stijndcl Aug 4, 2023
b9a30c0
Pass config token as param
stijndcl Aug 4, 2023
2f5b296
Small bugfix
stijndcl Aug 10, 2023
8f8f4e9
add `omitempty` to ConfirmationBlockObject.Deny
kamil-gwozdz Aug 14, 2023
dc27c00
Merge branch 'slack-go:master' into updating-modal
KouWakai Aug 15, 2023
311ff6a
change case "/humboldttest": to case "/slash" to handle http request …
KouWakai Aug 15, 2023
7b783e6
remove post message because it's not related to sample of updating modal
KouWakai Aug 15, 2023
6fe1bec
add time.sleep to wait to see updated modal
KouWakai Aug 15, 2023
80f6b07
Merge pull request #1215 from daabr/master
parsley42 Aug 18, 2023
49c50d0
Merge pull request #1224 from kamil-gwozdz/kamil-gwozdz-patch-1
parsley42 Aug 18, 2023
35d0f96
Merge pull request #1216 from nopcoder/master
parsley42 Aug 18, 2023
217f2de
Add examples
stijndcl Aug 18, 2023
cf4e8bc
add time pkg
KouWakai Aug 19, 2023
3dc3db8
Re-phrase example docs
stijndcl Aug 19, 2023
c806c9c
Merge pull request #1220 from stijndcl/manifests
parsley42 Aug 21, 2023
65cefed
Merge pull request #1150 from iaburton/safer-socketmode
parsley42 Aug 24, 2023
4c00dbd
Merge pull request #1212 from testwill/fmt
parsley42 Aug 29, 2023
b13e91d
Add is_enterprise_install flag to command, interactions, and oauth2 r…
hussachai Sep 10, 2023
b801caa
Add blocks in slackevents.MessageEvent
invzhi Sep 20, 2023
e439902
Add support for Rich Text Input
Oct 16, 2023
e715221
Add Video Block (#1210)
walkure Oct 21, 2023
1b0eb7d
Add rich_text_input block conv
Oct 24, 2023
f2fe7b3
Create openid.connect.token function to fetch access token
danielmichaels Nov 6, 2023
311e30d
Fix incorrectly commented functions
danielmichaels Nov 6, 2023
8019a9a
Improved comment for GetOpenIDConnectToken
danielmichaels Nov 6, 2023
fd060b6
Add RichTextList support
daniel-pieper-personio Nov 29, 2022
0f23d87
Add support for Indent field
daniel-pieper-personio Nov 8, 2023
2a4205d
Add block element type FileInput
elct9620 Dec 20, 2023
59faa0e
Add Files field related to FileInput element in the BlockAction
elct9620 Dec 21, 2023
4160354
add connected_team_ids, shared_team_ids, internal_team_ids, is_global…
zFlabmonsta Jan 20, 2024
07c76ba
Merge pull request #1253 from zFlabmonsta/master
parsley42 Jan 29, 2024
86cd1bd
Merge pull request #1227 from invzhi/master
parsley42 Jan 30, 2024
0ecd566
fix: expose is_enterprise_install field
Feb 1, 2024
e821170
Add "edited" field to the app mention event
zhshishkin Feb 1, 2024
cd8ca23
Merge branch 'slack-go:master' into richtext-list
daniel-pieper-personio Feb 2, 2024
bc6223b
Fix linter
daniel-pieper-personio Feb 2, 2024
53178c2
Fix: always add context to errors during block serde
yunginnanet Feb 7, 2024
f6b09b8
Merge pull request #1155 from daniel-pieper-personio/richtext-list
parsley42 Feb 9, 2024
e743e65
Add WithURL support for ButtonBlockElement
Feb 9, 2024
9d132f3
Merge pull request #1240 from peimanja/rich-text-input
parsley42 Feb 10, 2024
15f367e
Merge pull request #1259 from yunginnanet/master
parsley42 Feb 10, 2024
687e2d3
Merge pull request #1256 from IbirbyZh/add-edited-to-the-app-mention-…
parsley42 Feb 10, 2024
4c9f181
Merge pull request #1255 from 7ail/asee/is_enterprise_install
parsley42 Feb 10, 2024
c4923b2
Merge pull request #1250 from joshbranham/new-button-block-url
parsley42 Feb 10, 2024
ceb2250
Merge pull request #1249 from elct9620/add-file_input-element
parsley42 Feb 10, 2024
9cc451b
Merge pull request #1242 from danielmichaels/openid-connect
parsley42 Feb 10, 2024
fd5d171
Merge pull request #1225 from hussachai/enterprise_install
parsley42 Feb 10, 2024
398133c
Merge pull request #1142 from KouWakai/updating-modal
parsley42 Feb 10, 2024
e1cc0bf
add rich_text_quote and rich_text_preformatted
rusq Feb 11, 2024
a31aeaa
add deleted timestamp for deleted msg events
zFlabmonsta Feb 12, 2024
c038c02
Merge pull request #1261 from zFlabmonsta/master
parsley42 Feb 12, 2024
b6db972
Adding structure comments & definitions
Birtato Feb 14, 2024
5dbee1c
Merge pull request #1262 from Birtato/addSlackConnectEvents
parsley42 Feb 16, 2024
2a9c35c
Merge pull request #1260 from rusq/rich-text-stuff
parsley42 Feb 16, 2024
9a23f7a
Parse string or boolean for SlashCommand.IsEnterpriseInstall
kpaulisse Feb 20, 2024
af783b3
Merge pull request #1266 from kpaulisse/kpaulisse-is-enterprise-install
parsley42 Feb 26, 2024
fddc1a6
validate text length
Chagui- Mar 15, 2024
d2493fa
Merge pull request #1273 from Chagui-/master
parsley42 Mar 20, 2024
ce744b2
Add missing message option for link_names
Apr 18, 2024
3815306
Merge pull request #1278 from robbydyer/msg_opt_link_names
parsley42 Apr 18, 2024
e337d74
fix some typos
yutasb Apr 21, 2024
f0c1d7a
Merge pull request #1281 from yutasb/fix_typos
parsley42 Apr 22, 2024
b384934
ignore vendor
candiduslynx Apr 26, 2024
3a0fd11
bots.info
candiduslynx Apr 26, 2024
8b4dc51
chat.scheduledMessages.list
candiduslynx Apr 26, 2024
eb325a5
files.list
candiduslynx Apr 26, 2024
55bdd38
usergroups.create
candiduslynx Apr 26, 2024
0c1ba09
usergroups.list
candiduslynx Apr 26, 2024
a47d659
reactions.list
candiduslynx Apr 26, 2024
7138048
search.all
candiduslynx Apr 26, 2024
2824b31
team.accessLogs
candiduslynx Apr 26, 2024
204bf37
team.billableInfo
candiduslynx Apr 26, 2024
ceced00
team.profile.get
candiduslynx Apr 26, 2024
c530ebb
pr-prep
candiduslynx Apr 26, 2024
41fa1e5
Merge pull request #1283 from cloudquery/fix/expose-team_id-param
candiduslynx May 16, 2024
d959a37
Fix UploadFileV2 when using text content (#1291)
calebmckay Jun 6, 2024
f7a929c
Trigger GitHub Actions
lorenzoaiello Jul 14, 2024
006a688
Merge pull request #1208 from lheiskan/issue-1207
lorenzoaiello Jul 15, 2024
f7cac82
chore: slice replace loop (#1211)
testwill Jul 15, 2024
bc70fad
Add isReadOnly property to Conversation struct (#1232)
GGonryun Jul 15, 2024
ef53c0c
chore: make channel optional on `UploadFileV2` (#1293)
0xdeafcafe Jul 15, 2024
5094cdf
chore: Adding Deprecation Notice for files.upload (#1300)
lorenzoaiello Jul 15, 2024
cab4284
ci: Adding Go Test Coverage for 1.21 and 1.22 (#1298)
lorenzoaiello Jul 15, 2024
0a5c9e1
docs: Updating Inline Docs and API References (#1299)
lorenzoaiello Jul 15, 2024
ecfe504
docs: Add an example demonstrating correct usage of GetUsersPaginated…
adamrothman Jul 15, 2024
7ddfd02
docs: Adding an example for AddRemoteFile and DeleteFile (#1303)
lorenzoaiello Jul 15, 2024
1dfd1df
docs: Adding an example for ConversationHistory (#1302)
lorenzoaiello Jul 15, 2024
b9d4317
slackevents: support metadata in MessageEvent (#1307)
rfratto Jul 20, 2024
25fefc8
chore: replace ioutil with io or os package (#1310)
nakamasato Aug 15, 2024
75103a9
add file access field to file struct for slackevents (#1312)
zFlabmonsta Aug 15, 2024
99b3ebe
Add slack_file to image block (#1311)
rhysm Aug 15, 2024
e947079
feat: Events api reconcilation (#1306)
Aryakoste Aug 15, 2024
50e7414
feat: Add support for parsing AppRateLimited events (#1308)
nemuvski Aug 15, 2024
5345c06
feat: Add Properties.Canvas to Channel (#1228)
ku Aug 15, 2024
242df46
fix: create multipart form when multipart request (#1117)
EkeMinusYou Aug 15, 2024
11b3b95
feat: Add go version 1.23 to test matrix (test.yml) (#1315)
nemuvski Aug 20, 2024
38949f9
ci: Bump GitHub Actions to Latest Versions
shogo82148 Aug 20, 2024
5386d65
fix: fix deprecated comment for UploadFile and UploadFileContext (#1316)
shogo82148 Aug 21, 2024
6c4585b
Support publishing a messge to a specific thread (#1309)
Nikolo Sep 17, 2024
cd4e26e
fix: Add required `format` field to rich text date blocks (#1317)
luke-josh Sep 17, 2024
6998189
fix: Updated RichTextInputBlockElement InitialValue data type (#1320)
Manjish Sep 19, 2024
447b7cd
feat: Add support for unicode parameter in emoji type of rich text bl…
YutoKashiwagi Sep 19, 2024
57aa84d
Add endpoints for `calls.*` apis and `Type: call` in blockkit (#1190)
winston-stripe Oct 14, 2024
132e0d1
feat: Add Convenience Methods to Block Elements (#1279)
obed-sj Oct 14, 2024
21e61c5
feat: Add functions.completeError and functions.completeSuccess (#1328)
gideonw Oct 14, 2024
c5ef90e
feat: Add support for external_limited option of inviteShared (#1330)
bamo Oct 14, 2024
203cdb2
feat: Add support for Canvas API methods (#1334)
jarospisak-unity Oct 14, 2024
61f5761
Merge remote-tracking branch 'upstream/master' into kelsey/resp-4311-…
kelseymills Nov 5, 2024
573832b
Add back a few things I removed from our version when merging
kelseymills Nov 5, 2024
01f17e8
Remove duplicate TeamID
kelseymills Nov 5, 2024
1e4725e
Fix tests
kelseymills Nov 5, 2024
0c1f7fe
Fix linting
kelseymills Nov 6, 2024
3601e01
Implement interface for generic section
kelseymills Nov 6, 2024
e7279fc
Fix methods to generate new rich text types
kelseymills Nov 6, 2024
85a6fc8
Implement set elements
kelseymills Nov 7, 2024
2219a43
Revert rich text changes
kelseymills Nov 7, 2024
d736151
Delete unnecessary file
kelseymills Nov 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/stale.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Close stale issues and PRs'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✂️

on:
schedule:
- cron: '0 0 * * 1' # every Monday 0:00 UTC

workflow_dispatch:

permissions:
issues: write
pull-requests: write

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
with:
any-of-labels: 'feedback given'
days-before-stale: 45
days-before-pr-close: 10
stale-issue-message: 'This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
close-issue-message: 'This issue was closed because it has been stalled for 10 days with no activity.'
close-pr-message: 'This PR was closed because it has been stalled for 10 days with no activity.'
operations-per-run: 120
21 changes: 14 additions & 7 deletions .github/workflows/test.yml
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this had conflicts but the tests & linter run and pass so not much danger here

Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ jobs:
strategy:
matrix:
go:
- '1.17'
- '1.18'
- '1.19'
- '1.20'
- '1.21'
- '1.22'
- '1.23'
name: test go-${{ matrix.go }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: run test
Expand All @@ -29,13 +32,17 @@ jobs:
runs-on: ubuntu-22.04
name: lint
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version: '1.20'
cache: false
- uses: actions/checkout@v4
with:
# NOTE: Because we are a fork,
# we must fetch all history for all branches
# and tags.
fetch-depth: '0'
fetch-depth: 0
- name: golangci-lint
uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc # v3.2.0
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
version: v1.49.0
version: v1.52.2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.test
*~
.idea/
/vendor/
10 changes: 9 additions & 1 deletion apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ type EventAuthorization struct {
IsEnterpriseInstall bool `json:"is_enterprise_install"`
}

// ListEventAuthorizations lists authed users and teams for the given event_context.
// You must provide an app-level token to the client using OptionAppLevelToken.
// For more details, see ListEventAuthorizationsContext documentation.
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
// ListEventAuthorizationsContext lists authed users and teams for the given event_context with a custom context.
// Slack API docs: https://api.slack.com/methods/apps.event.authorizations.list
func (api *Client) ListEventAuthorizationsContext(ctx context.Context, eventContext string) ([]EventAuthorization, error) {
resp := &listEventAuthorizationsResponse{}

Expand All @@ -43,10 +47,14 @@ func (api *Client) ListEventAuthorizationsContext(ctx context.Context, eventCont
return resp.Authorizations, nil
}

// UninstallApp uninstalls your app from a workspace.
// For more details, see UninstallAppContext documentation.
func (api *Client) UninstallApp(clientID, clientSecret string) error {
return api.UninstallAppContext(context.Background(), clientID, clientSecret)
}

// UninstallAppContext uninstalls your app from a workspace with a custom context.
// Slack API docs: https://api.slack.com/methods/apps.uninstall
func (api *Client) UninstallAppContext(ctx context.Context, clientID, clientSecret string) error {
values := url.Values{
"client_id": {clientID},
Expand Down
11 changes: 7 additions & 4 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ func (api *Client) authRequest(ctx context.Context, path string, values url.Valu
return response, response.Err()
}

// SendAuthRevoke will send a revocation for our token
// SendAuthRevoke will send a revocation for our token.
// For more details, see SendAuthRevokeContext documentation.
func (api *Client) SendAuthRevoke(token string) (*AuthRevokeResponse, error) {
return api.SendAuthRevokeContext(context.Background(), token)
}

// SendAuthRevokeContext will send a revocation request for our token to api.revoke with context
// SendAuthRevokeContext will send a revocation request for our token to api.revoke with a custom context.
// Slack API docs: https://api.slack.com/methods/auth.revoke
func (api *Client) SendAuthRevokeContext(ctx context.Context, token string) (*AuthRevokeResponse, error) {
if token == "" {
token = api.token
Expand All @@ -52,12 +54,13 @@ type ListTeamsParameters struct {
}

// ListTeams returns all workspaces a token can access.
// More info: https://api.slack.com/methods/admin.teams.list
// For more details, see ListTeamsContext documentation.
func (api *Client) ListTeams(params ListTeamsParameters) ([]Team, string, error) {
return api.ListTeamsContext(context.Background(), params)
}

// ListTeams returns all workspaces a token can access with a custom context.
// ListTeamsContext returns all workspaces a token can access with a custom context.
// Slack API docs: https://api.slack.com/methods/auth.teams.list
func (api *Client) ListTeamsContext(ctx context.Context, params ListTeamsParameters) ([]Team, string, error) {
values := url.Values{
"token": {api.token},
Expand Down
2 changes: 2 additions & 0 deletions block.go
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this had some minor conflicts because we had implemented our own call block, but I've replaced it entirely with theirs

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
MBTHeader MessageBlockType = "header"
MBTRichText MessageBlockType = "rich_text"
MBTCall MessageBlockType = "call"
MBTVideo MessageBlockType = "video"
)

// Block defines an interface all block types should implement
Expand All @@ -41,6 +42,7 @@ type BlockAction struct {
Text TextBlockObject `json:"text"`
Value string `json:"value"`
RichTextValue RichTextBlock `json:"rich_text_value"`
Files []File `json:"files"`
ActionTs string `json:"action_ts"`
SelectedOption OptionBlockObject `json:"selected_option"`
SelectedOptions []OptionBlockObject `json:"selected_options"`
Expand Down
59 changes: 15 additions & 44 deletions block_call.go
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this had some minor conflicts because we had implemented our own call block, but I've replaced it entirely with theirs

Original file line number Diff line number Diff line change
@@ -1,53 +1,24 @@
package slack

// CallBlock defines information
// CallBlock defines data that is used to display a call in slack.
//
// More Information: https://api.slack.com/apis/calls#post_to_channel
type CallBlock struct {
Type MessageBlockType `json:"type"`
CallID string `json:"call_id"`
BlockID string `json:"block_id"`
APIDecorationAvailable bool `json:"api_decoration_available"`
Call Call `json:"call"`
}

type AppIconUrls struct {
Image32 string `json:"image_32"`
Image36 string `json:"image_36"`
Image48 string `json:"image_48"`
Image64 string `json:"image_64"`
Image72 string `json:"image_72"`
Image96 string `json:"image_96"`
Image128 string `json:"image_128"`
Image192 string `json:"image_192"`
Image512 string `json:"image_512"`
Image1024 string `json:"image_1024"`
ImageOriginal string `json:"image_original"`
}
type CallInfo struct {
ID string `json:"id"`
AppID string `json:"app_id"`
AppIconUrls AppIconUrls `json:"app_icon_urls"`
DateStart int `json:"date_start"`
ActiveParticipants []interface{} `json:"active_participants"`
AllParticipants []interface{} `json:"all_participants"`
DisplayID string `json:"display_id"`
JoinURL string `json:"join_url"`
DesktopAppJoinURL string `json:"desktop_app_join_url"`
Name string `json:"name"`
CreatedBy string `json:"created_by"`
DateEnd int `json:"date_end"`
Channels []string `json:"channels"`
IsDmCall bool `json:"is_dm_call"`
WasRejected bool `json:"was_rejected"`
WasMissed bool `json:"was_missed"`
WasAccepted bool `json:"was_accepted"`
HasEnded bool `json:"has_ended"`
}
type Call struct {
CallInfo CallInfo `json:"v1"`
MediaBackendType string `json:"media_backend_type"`
Type MessageBlockType `json:"type"`
BlockID string `json:"block_id,omitempty"`
CallID string `json:"call_id"`
Call Call `json:"call"`
}

// BlockType returns the type of the block
func (s CallBlock) BlockType() MessageBlockType {
return s.Type
}

// NewCallBlock returns a new instance of a file block
func NewCallBlock(callID string) *CallBlock {
return &CallBlock{
Type: MBTCall,
CallID: callID,
}
}
13 changes: 13 additions & 0 deletions block_call_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package slack

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestNewCallBlock(t *testing.T) {
callBlock := NewCallBlock("ACallID")
assert.Equal(t, string(callBlock.Type), "call")
assert.Equal(t, callBlock.CallID, "ACallID")
}
9 changes: 6 additions & 3 deletions block_conv.go
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this had some minor conflicts because we had implemented our own call block, but I've replaced it entirely with theirs

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package slack

import (
"encoding/json"
"errors"
"fmt"
)

Expand Down Expand Up @@ -72,6 +71,8 @@ func (b *Blocks) UnmarshalJSON(data []byte) error {
block = &SectionBlock{}
case "call":
block = &CallBlock{}
case "video":
block = &VideoBlock{}
default:
block = &UnknownBlock{}
}
Expand Down Expand Up @@ -136,8 +137,10 @@ func (b *InputBlock) UnmarshalJSON(data []byte) error {
e = &RadioButtonsBlockElement{}
case "number_input":
e = &NumberInputBlockElement{}
case "file_input":
e = &FileInputBlockElement{}
default:
return errors.New("unsupported block element type")
return fmt.Errorf("unsupported block element type %v", s.TypeVal)
}

if err := json.Unmarshal(a.Element, e); err != nil {
Expand Down Expand Up @@ -443,7 +446,7 @@ func (e *ContextElements) UnmarshalJSON(data []byte) error {

e.Elements = append(e.Elements, elem.(*ImageBlockElement))
default:
return errors.New("unsupported context element type")
return fmt.Errorf("unsupported context element type %v", contextElementType)
}
}

Expand Down
Loading