-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Having read a lot of Slack documentation and operated v2.0.0.3 in production for a bit, I now understand that the Slack message attachment field is poorly standardized. None of the fields are required and there are different versions of the attachments api over the years that are all supported in this one field. To make apps that look at attachments, chance are, you're going to need to look at the raw json value. So I've edited slack-web to try to decode the attachment based on documented schema (and ported from Slack's own open source javascript sdks) but then also pass the raw json value to clients. Before submitting your PR, check that you've: - [x] Documented new APIs with [Haddock markup](https://www.haskell.org/haddock/doc/html/index.html) - [x] Added [`@since` declarations](http://haskell-haddock.readthedocs.io/en/latest/markup.html#since) to the Haddock After submitting your PR: - [x] Update the Changelog.md file with a link to your PR - [x] Bumped the version number if there isn't an `(unreleased)` on the Changelog - [x] Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)
- Loading branch information
Showing
16 changed files
with
1,619 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
cabal-version: 2.2 | ||
name: slack-web | ||
version: 2.0.0.3 | ||
version: 2.0.0.4 | ||
|
||
build-type: Simple | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
254 changes: 201 additions & 53 deletions
254
tests/golden/SlackWebhookEvent/forwarded_message.golden
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 197 additions & 0 deletions
197
tests/golden/SlackWebhookEvent/github_notification.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
EventEventCallback | ||
( EventCallback | ||
{ eventId = EventId | ||
{ unEventId = "Ev07MH6R7FDE" } | ||
, teamId = TeamId | ||
{ unTeamId = "T043DB835ML" } | ||
, eventTime = MkSystemTime | ||
{ systemSeconds = 1725998548 | ||
, systemNanoseconds = 0 | ||
} | ||
, event = EventMessage | ||
( MessageEvent | ||
{ blocks = Nothing | ||
, channel = ConversationId | ||
{ unConversationId = "C07LRFB3C8M" } | ||
, text = "" | ||
, channelType = Channel | ||
, files = Nothing | ||
, user = UserId | ||
{ unUserId = "U07M725KAD7" } | ||
, ts = "1725998548.581159" | ||
, threadTs = Nothing | ||
, appId = Just "A01BP7R4KNY" | ||
, botId = Just "B07LDR01Z63" | ||
, attachments = Just | ||
[ MessageAttachment | ||
{ decoded = Just | ||
( DecodedMessageAttachment | ||
{ fallback = Just "[myorg/myrepo] Issue opened by ldub" | ||
, color = Just "36a64f" | ||
, pretext = Just "Issue created by <https://github.com/ldub|ldub>" | ||
, authorName = Nothing | ||
, authorLink = Nothing | ||
, authorIcon = Nothing | ||
, title = Just "<https://github.com/myorg/myrepo/issues/2|#2 test issue 2>" | ||
, titleLink = Nothing | ||
, text = Just "another oneeeee" | ||
, fields = Nothing | ||
, imageUrl = Nothing | ||
, thumbUrl = Nothing | ||
, footer = Just "<https://github.com/myorg/myrepo|myorg/myrepo>" | ||
, footerIcon = Just "https://slack.github.com/static/img/favicon-neutral.png" | ||
, ts = Just "1725998545.0" | ||
, isMsgUnfurl = Nothing | ||
, messageBlocks = Nothing | ||
, authorId = Nothing | ||
, channelId = Nothing | ||
, channelTeam = Nothing | ||
, isAppUnfurl = Nothing | ||
, appUnfurlUrl = Nothing | ||
, fromUrl = Nothing | ||
} | ||
) | ||
, raw = Object | ||
( fromList | ||
[ | ||
( "actions" | ||
, Array | ||
[ Object | ||
( fromList | ||
[ | ||
( "id" | ||
, String "1" | ||
) | ||
, | ||
( "name" | ||
, String "comment" | ||
) | ||
, | ||
( "style" | ||
, String "" | ||
) | ||
, | ||
( "text" | ||
, String "Comment" | ||
) | ||
, | ||
( "type" | ||
, String "button" | ||
) | ||
, | ||
( "value" | ||
, String "{&amp;quot;selectedOrg&amp;quot;:&amp;quot;myorg&amp;quot;,&amp;quot;selectedOrgId&amp;quot;:140364112,&amp;quot;selectedRepo&amp;quot;:&amp;quot;myrepo&amp;quot;,&amp;quot;selectedRepoId&amp;quot;:809927288,&amp;quot;issueNumber&amp;quot;:2,&amp;quot;issueHtmlUrl&amp;quot;:&amp;quot;https://github.com/myorg/myrepo/issues/2&amp;quot;,&amp;quot;issueTitle&amp;quot;:&amp;quot;test issue 2&amp;quot;}" | ||
) | ||
] | ||
) | ||
, Object | ||
( fromList | ||
[ | ||
( "id" | ||
, String "2" | ||
) | ||
, | ||
( "name" | ||
, String "edit" | ||
) | ||
, | ||
( "style" | ||
, String "" | ||
) | ||
, | ||
( "text" | ||
, String "Edit" | ||
) | ||
, | ||
( "type" | ||
, String "button" | ||
) | ||
, | ||
( "value" | ||
, String "{&amp;quot;selectedOrg&amp;quot;:&amp;quot;myorg&amp;quot;,&amp;quot;selectedOrgId&amp;quot;:140364112,&amp;quot;selectedRepo&amp;quot;:&amp;quot;myrepo&amp;quot;,&amp;quot;selectedRepoId&amp;quot;:809927288,&amp;quot;issueNumber&amp;quot;:2,&amp;quot;issueHtmlUrl&amp;quot;:&amp;quot;https://github.com/myorg/myrepo/issues/2&amp;quot;,&amp;quot;issueTitle&amp;quot;:&amp;quot;test issue 2&amp;quot;}" | ||
) | ||
] | ||
) | ||
, Object | ||
( fromList | ||
[ | ||
( "id" | ||
, String "3" | ||
) | ||
, | ||
( "name" | ||
, String "close" | ||
) | ||
, | ||
( "style" | ||
, String "danger" | ||
) | ||
, | ||
( "text" | ||
, String "Close" | ||
) | ||
, | ||
( "type" | ||
, String "button" | ||
) | ||
, | ||
( "value" | ||
, String "{&amp;quot;selectedOrg&amp;quot;:&amp;quot;myorg&amp;quot;,&amp;quot;selectedOrgId&amp;quot;:140364112,&amp;quot;selectedRepo&amp;quot;:&amp;quot;myrepo&amp;quot;,&amp;quot;selectedRepoId&amp;quot;:809927288,&amp;quot;issueNumber&amp;quot;:2,&amp;quot;issueHtmlUrl&amp;quot;:&amp;quot;https://github.com/myorg/myrepo/issues/2&amp;quot;,&amp;quot;issueTitle&amp;quot;:&amp;quot;test issue 2&amp;quot;}" | ||
) | ||
] | ||
) | ||
] | ||
) | ||
, | ||
( "callback_id" | ||
, String "issue-opened-interaction" | ||
) | ||
, | ||
( "color" | ||
, String "36a64f" | ||
) | ||
, | ||
( "fallback" | ||
, String "[myorg/myrepo] Issue opened by ldub" | ||
) | ||
, | ||
( "footer" | ||
, String "<https://github.com/myorg/myrepo|myorg/myrepo>" | ||
) | ||
, | ||
( "footer_icon" | ||
, String "https://slack.github.com/static/img/favicon-neutral.png" | ||
) | ||
, | ||
( "id" | ||
, Number 1.0 | ||
) | ||
, | ||
( "mrkdwn_in" | ||
, Array | ||
[ String "text" ] | ||
) | ||
, | ||
( "pretext" | ||
, String "Issue created by <https://github.com/ldub|ldub>" | ||
) | ||
, | ||
( "text" | ||
, String "another oneeeee" | ||
) | ||
, | ||
( "title" | ||
, String "<https://github.com/myorg/myrepo/issues/2|#2 test issue 2>" | ||
) | ||
, | ||
( "ts" | ||
, Number 1.725998545e9 | ||
) | ||
] | ||
) | ||
} | ||
] | ||
} | ||
) | ||
} | ||
) |
Oops, something went wrong.