webhooks/teamcity: Use check_send_webhook_message.

For a personal build, the teamcity webhook still sends a private
message using check_send_private_message since a personal build
should never trigger a public notification.

For a non-personal build, check_send_webhook_message is used,
which can either send a PM or a stream message based on whether
a stream is specified in the webhook URL or not.
This commit is contained in:
Eeshan Garg 2018-03-17 14:56:27 -02:30 committed by Tim Abbott
parent 3dafbfa5f4
commit 857569cbf7
1 changed files with 4 additions and 5 deletions

View File

@ -8,10 +8,10 @@ from django.db.models import Q
from django.http import HttpRequest, HttpResponse
from zerver.decorator import api_key_only_webhook_view
from zerver.lib.actions import check_send_private_message, \
check_send_stream_message
from zerver.lib.actions import check_send_private_message
from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success
from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import Realm, UserProfile
def guess_zulip_user_from_teamcity(teamcity_username: str, realm: Realm) -> Optional[UserProfile]:
@ -38,8 +38,7 @@ def get_teamcity_property_value(property_list: List[Dict[str, str]], name: str)
@api_key_only_webhook_view('Teamcity')
@has_request_variables
def api_teamcity_webhook(request: HttpRequest, user_profile: UserProfile,
payload: Dict[str, Any]=REQ(argument_type='body'),
stream: str=REQ(default='teamcity')) -> HttpResponse:
payload: Dict[str, Any]=REQ(argument_type='body')) -> HttpResponse:
message = payload['build']
build_name = message['buildFullName']
@ -97,5 +96,5 @@ def api_teamcity_webhook(request: HttpRequest, user_profile: UserProfile,
return json_success()
check_send_stream_message(user_profile, request.client, stream, topic, body)
check_send_webhook_message(request, user_profile, topic, body)
return json_success()