Skip to content
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

Merged
merged 6 commits into from
Jun 20, 2018

Conversation

MarcosSpessatto
Copy link
Member

@MarcosSpessatto MarcosSpessatto commented Apr 13, 2018

Add parameter to REST chat.react endpoint, to make it work like a setter
Closes #10370.

@MarcosSpessatto MarcosSpessatto self-assigned this Apr 13, 2018
@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-10447 April 13, 2018 18:41 Inactive
@MarcosSpessatto MarcosSpessatto changed the title [FIX] Add parameter to REST chat.react endpoint, to make it work like a toggle [FIX] Add parameter to REST chat.react endpoint, to make it work like a setter Apr 17, 2018
@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-10447 April 24, 2018 14:58 Inactive
Copy link
Member

@ggazzo ggazzo left a 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) {
Copy link
Member

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;
}

Copy link
Member Author

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?

Copy link
Member

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...

Copy link
Contributor

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.

Copy link
Contributor

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"

Copy link
Contributor

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.

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-10447 June 14, 2018 14:39 Inactive
@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-10447 June 19, 2018 20:26 Inactive
@ggazzo
Copy link
Member

ggazzo commented Jun 19, 2018

@MarcosSpessatto
Copy link
Member Author

@ggazzo ggazzo merged commit b941169 into develop Jun 20, 2018
@ggazzo ggazzo deleted the fix-rest-chat-react branch June 20, 2018 19:27
@rodrigok rodrigok mentioned this pull request Jun 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants