-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
Fix for issues #38 and #126 #143
base: master
Are you sure you want to change the base?
Conversation
@rampatra ping? |
Hi @davidkarlsen, thanks a lot for contributing. Before reviewing/merging I would like to understand a bit more about encoding in Slack. From the slack docs, it says:
So, exactly when do we need to NOT encode the message? |
See: #38 (comment) and the link there - <> have special meaning (linking) in slack - and thus you want to not encode them into < etc |
So, Slack at first asks to convert |
@rampatra did you follow? do you need more info? |
@rampatra ping? |
@davidkarlsen what I am trying to say is that we can make the encrypt function intelligent enough to encrypt just In other words, your PR is fine as it allows the user to override the encrypt function. I was just suggesting to make the default encrypt function intelligent enough so that the user doesn't even feel the need to override. |
Maybe that can be done later - if you merge it now we can get back to that. |
Ping |
👋 May I interrupt in your discussion? Pluggable encoder is a nice workaround but in term of API, I'm not a big fan of it. In my mind, I would see this kind of API instead:
That will produce:
It exclude the reference to the user but it change the last You can find a Poc here: (the better would be to detect directly "<@345f>" as a slack user id, but if the developer doesn't to, you can badly interpret the string) Regards |
hey @dwursteisen, I got what your method is doing, however, I did not completely understand how one would pass the user mentions (the user ids) to exclude to this method? |
If you're replying to someone, you do have his ID somewhere. For example, I use a slack bot to pick a random user from a list. So, what i'm doing is: @Controller(events = EventType.DIRECT_MENTION)
public void pickUser(WebSocketSession session, Event event) {
String pickedUser = randomUser();
// did you notice that I have also updated the reply method?
reply(session, event, "I choose…" + pickedUser + " as the winner!", pickedUser);
} |
@dwursteisen yes, this would only work for this case where you have the receiver id and pass it to your reply method. But what if a message has multiple mentions? For example, user A can target a message to user B, user C, etc. Consider this message from user A on a slack channel, |
// the last argument is a varargs.
reply(session, event, "<@userB> <@userC> you both are late for this", "<@userB>", "<@userC>"); |
This simple change provides a pluggable way to change the encoding - including none at all which is a workaround for #38 and #126
This change is