-
Notifications
You must be signed in to change notification settings - Fork 6
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
Optionally use Slack's web API instead of per-channel webhooks #94
Merged
Conversation
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
yasunariw
changed the title
Yasu/slack webhook to api
Use Slack's web API instead of per-channel webhooks
Dec 21, 2020
yasunariw
force-pushed
the
yasu/upgrade-status-rules
branch
from
December 23, 2020 11:45
8730f89
to
b47ab24
Compare
yasunariw
force-pushed
the
yasu/slack-webhook-to-api
branch
from
December 23, 2020 12:00
94779d8
to
76762b0
Compare
yasunariw
force-pushed
the
yasu/upgrade-status-rules
branch
from
December 24, 2020 02:19
b47ab24
to
24e0c4f
Compare
yasunariw
force-pushed
the
yasu/slack-webhook-to-api
branch
from
December 24, 2020 03:17
f179fc8
to
6e6ae96
Compare
yasunariw
force-pushed
the
yasu/slack-webhook-to-api
branch
4 times, most recently
from
December 30, 2020 12:43
cf9b42f
to
d527ce4
Compare
ygrek
suggested changes
Dec 30, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for exhaustive PR descriptions and docs
yasunariw
force-pushed
the
yasu/slack-webhook-to-api
branch
from
December 31, 2020 06:05
0060a7b
to
9bd0cae
Compare
yasunariw
changed the title
Use Slack's web API instead of per-channel webhooks
Optionally use Slack's web API instead of per-channel webhooks
Dec 31, 2020
ygrek
approved these changes
Dec 31, 2020
Slack Webhooks and Web API should be able to share the same payload structure.
Adds a way to send notifications without per-channel webhooks. The sending mechanism will authenticate with a bearer token that is valid for any channel that the bot has been added to. The channel is specified in a new `channel` field in the notification payload. A note on error handling: for web API requests, Slack always returns a 200 response and communicates the error message in the response body, so checking for status alone isn't enough.
yasunariw
force-pushed
the
yasu/slack-webhook-to-api
branch
from
January 4, 2021 02:51
6e18496
to
7404d4a
Compare
ygrek
reviewed
Jan 4, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the task
Send Slack notifications by querying the API with an access token instead of querying per-channel webhooks.
As per #56, it's cumbersome to generate and maintain an incoming webhook per Slack channel, especially when there are multiple channels to message.
If the user can configure an access token, they can use the single token to message any channel that the bot is added to. This is a one-time setup, so additional channels can be configured later on without providing a webhook URL for it.
Summary:
notification
inslack.atd
: The API endpoint expects the channel to be provided as a field in the request body.send_notification
inapi_remote.ml
: Modified to use the stored access token to authenticate and send a message to thechat.postMessage
API endpoint, falling back on webhooks if unable to find a token.ok
field in the payload, so checking for status code alone isn't enough to catch errors:(How to test
Existing tests were promoted as the slack payload now contains a
channel
field, but otherwise no regressions.Additional tests were run on a dummy Slack workspace to check oauth behavior.
References
postMessage
API endpoint that replaces webhooks