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

outgoing webhooks: Warn user that PMs are not supported in Slack-format webhook. #9814

Closed
wants to merge 2 commits into from

Conversation

rheaparekh
Copy link
Collaborator

Private messages are not supported in Slack-format webhook. Instead of raising a NotImplementedError, we warn the user that PM service is not supported by sending a message to the user.
Added tests for the same.

Fixes #9239

Screenshot:
screen shot 2018-06-24 at 12 27 58 pm

@zulipbot
Copy link
Member

Hello @zulip/server-bots members, this pull request was labeled with the "area: bots" label, so you may want to check it out!

@rheaparekh rheaparekh force-pushed the slack_webhook branch 2 times, most recently from 8bab95d to 88d651e Compare June 25, 2018 15:23
@rheaparekh
Copy link
Collaborator Author

@timabbott This is ready for a review.

Copy link
Contributor

@neiljp neiljp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks broadly fine to me.

I would question the text to use in the response to the user; on one hand I see it useful to be simple at simply stating the feature is not supported, but it also may be nice to have a little detail as to the context (maybe in parentheses after?) to show the source of the limitation?

@@ -479,7 +479,8 @@ def consume(self, event: Mapping[str, Any]) -> None:
dup_event['service_name'] = str(service.name)
service_handler = get_outgoing_webhook_service_handler(service)
rest_operation, request_data = service_handler.process_event(dup_event)
do_rest_call(rest_operation, request_data, dup_event, service_handler)
if request_data:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the addition of this? do_rest_call previously is specified as accepting an Optional request_data parameter, so is this warranted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am returning a None here, as I don't want the function do_rest_call to proceed ahead for private messages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the correlation to private slack messages, but this code applies generally to outgoing webhooks, not just slack?

@@ -54,7 +54,7 @@ def test_process_success(self) -> None:
class TestSlackOutgoingWebhookService(ZulipTestCase):

def setUp(self) -> None:
self.event = {
self.stream_message_event = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit just covers a rename for the sake of clarity, correct? If so, consider simply saying so in the commit title, eg. "Rename [blah] for clarity."

@rheaparekh
Copy link
Collaborator Author

This is ready for a review.

@rheaparekh rheaparekh force-pushed the slack_webhook branch 2 times, most recently from 9d6802b to a280ca3 Compare August 3, 2018 22:06
…at webhook.

Private messages are not supported in Slack-format webhook.
Instead of raising a NotImplementedError, we warn the user
that PM service is not supported by sending a message to the
user.

Added tests for the same.

Fixes zulip#9239
@timabbott
Copy link
Sponsor Member

Rebased and merged, after fixing the super confusing error message "Private messaging service not supported". Thanks @rheaparekh!

@timabbott timabbott closed this Aug 10, 2018
@rheaparekh rheaparekh deleted the slack_webhook branch August 13, 2018 00:18
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.

None yet

4 participants