-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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] Add parameter to REST chat.react endpoint, to make it work like a setter #10447
Conversation
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.
;)
if (message.reactions[reaction].usernames.length === 0) { | ||
delete message.reactions[reaction]; | ||
} | ||
}; | ||
if (userAlreadyReacted) { |
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.
why not just do something like?
if(userAlreadyReacted === shouldReact) {
return;
}
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.
I think we should not simply return if they are the same in this case, because if we do not throw an error when we try to react in a message already reacted, the REST API will end up returning success, without actually having performed the react action. What do you think?
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.
I'm not sure... but this change aims allow set the reaction instead toggle. if you want react but you already reacted, I think you got it, its not a ERROR...
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.
I think there's no need to throw an error if the end result is going to be the same as when the method is successful.
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.
We'd need to change quite a few REST things, then. We have more methods that error with "The current status is the same as it would be set to"
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.
It's something that is worth looking into, then. We should get everybody's opinion on which approach is better and then standardize every method.
@MarcosSpessatto could you update the docs? |
@ggazzo here it is https://github.com/RocketChat/docs/pull/804 ;) |
Add parameter to REST chat.react endpoint, to make it work like a setter
Closes #10370.