Description
Improvements for symfony/slack-notifier
The generic channel
option
The problem:
Right now you can provide a channel=
option, and you can pass nearly everything... 🤔
CHANNEL
is a channel, private group, or IM channel to send message to, it can be an encoded ID, or a name.
This is the full DSN: SLACK_DSN=slack://TOKEN@default?channel=CHANNEL
I tried a lot to figure out WHAT you need to pass exactly:
- If you want to wrote to the channel
#support
->?channel=support
✅ - If you want to wrote to the user
@OskarStark
->?channel=@OskarStark
✅ - If you want to wrote to the user
@OskarStark
you can also use the UserId, which can be found in your profile ->?channel=U68xxxx
🤔 ✅
So far this looks ok, but there are some pitfalls we can avoid. One would think he can just use:
?channel=#support
❌ NO # sign allowed 😮?channel=OskarStark
❌ NO, @ sign needed 😮?channel=@U68xxxx
❌ NO @ sign allowed 😮
My proposal:
A new user=
(or handle
=) and user_id=
parameter.
We can now validate, that a channel must not start with #
, a user must start with @
and a user_id must not start with @
(maybe it also has a dedicated length which can be taken into account).
So valid DSN would be:
- slack://TOKEN@default?channel=support
- slack://TOKEN@default?user=@OskarStark // slack://TOKEN@default?handle=@OskarStark
- slack://TOKEN@default?user_id=@U68xxxx
The correct token - PR #39606
The Problem:
Because we switched back and forth from a token to a webhook_id, which can be considered a "token" too, it could be hard to find out, if you are using the correct token.
My proposal:
Let's validate the token syntax in the transport and give a clear error message.
Slack has a clear syntax for their tokens which makes us able to validate the syntax before we perform a request.
- Bot user token strings begin with
xoxb-
- User token strings begin with
xoxp-
- Workspace access token strings begin with
xoxa-2
Questions
- What type of token do you use?
- Are you using any other ids, channel-names etc. ?
cc @malteschlueter as we both had some trouble in the past