From 707898b236bf648828eaaebad9f9c42f7dd17b72 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Wed, 21 Aug 2013 13:10:22 -0400 Subject: [PATCH] bitbucket: Allow the stream to be specified (imported from commit eea7392551b568502c01e59c89056b4369fe53e0) --- templates/zerver/integrations.html | 7 ++++++- zerver/views.py | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/templates/zerver/integrations.html b/templates/zerver/integrations.html index 3238cedcf3..38d9bf98cb 100644 --- a/templates/zerver/integrations.html +++ b/templates/zerver/integrations.html @@ -83,9 +83,14 @@ Choose the POST hook from the list presented and click "Add hook." Make sure to replace the @ in the bot's email address with %40, as Bitbucket will not execute the hook if the username contains a @.

-

In the URL field, enter https://bot_email:bot_api_key@api.zulip.com/v1/external/bitbucket:

+

In the URL field, enter https://bot_email:bot_api_key@api.zulip.com/v1/external/bitbucket:

+

By default, notifications are sent to + the commits stream. To send notifications to a + different stream, append ?stream=stream_name to + the URL. The stream must already exist.

+

Congratulations! You're done!
Whenever you push code to your repository, you'll get an automated notification that looks like this:

diff --git a/zerver/views.py b/zerver/views.py index 68c4721e72..b09563ecfe 100644 --- a/zerver/views.py +++ b/zerver/views.py @@ -2088,7 +2088,8 @@ def get_status_list(requesting_user_profile): @authenticated_rest_api_view @has_request_variables -def api_bitbucket_webhook(request, user_profile, payload=REQ(converter=json_to_dict)): +def api_bitbucket_webhook(request, user_profile, payload=REQ(converter=json_to_dict), + stream=REQ(default='commits')): repository = payload['repository'] commits = [{'id': commit['raw_node'], 'message': commit['message'], 'url': '%s%scommits/%s' % (payload['canon_url'], @@ -2108,7 +2109,7 @@ def api_bitbucket_webhook(request, user_profile, payload=REQ(converter=json_to_d None, payload['user']) subject = elide_subject(subject) - check_send_message(user_profile, get_client("API"), "stream", ["commits"], subject, content) + check_send_message(user_profile, get_client("API"), "stream", [stream], subject, content) return json_success() @authenticated_json_post_view