2016-12-02 12:06:20 +01:00
|
|
|
# Webhooks for external integrations.
|
|
|
|
|
|
|
|
from django.http import HttpRequest, HttpResponse
|
|
|
|
|
2017-10-31 04:25:48 +01:00
|
|
|
from zerver.decorator import api_key_only_webhook_view
|
|
|
|
from zerver.lib.request import REQ, has_request_variables
|
2017-11-16 00:43:10 +01:00
|
|
|
from zerver.lib.response import json_success
|
2018-03-16 22:53:50 +01:00
|
|
|
from zerver.lib.webhooks.common import check_send_webhook_message
|
2017-05-02 01:00:50 +02:00
|
|
|
from zerver.models import UserProfile
|
2016-12-02 12:06:20 +01:00
|
|
|
|
2018-11-20 18:52:25 +01:00
|
|
|
@api_key_only_webhook_view("Heroku", notify_bot_owner_on_invalid_json=False)
|
2016-12-02 12:06:20 +01:00
|
|
|
@has_request_variables
|
2017-12-06 11:10:32 +01:00
|
|
|
def api_heroku_webhook(request: HttpRequest, user_profile: UserProfile,
|
2018-05-10 19:34:01 +02:00
|
|
|
head: str=REQ(), app: str=REQ(), user: str=REQ(),
|
|
|
|
url: str=REQ(), git_log: str=REQ()) -> HttpResponse:
|
2018-06-29 18:00:44 +02:00
|
|
|
template = "{} deployed version {} of [{}]({})\n``` quote\n{}\n```"
|
2016-12-02 12:06:20 +01:00
|
|
|
content = template.format(user, head, app, url, git_log)
|
|
|
|
|
2018-03-16 22:53:50 +01:00
|
|
|
check_send_webhook_message(request, user_profile, app, content)
|
2016-12-02 12:06:20 +01:00
|
|
|
return json_success()
|