2016-12-02 12:06:20 +01:00
|
|
|
# Webhooks for external integrations.
|
|
|
|
from typing import Text
|
|
|
|
|
|
|
|
from django.http import HttpRequest, HttpResponse
|
|
|
|
|
2017-10-31 04:25:48 +01:00
|
|
|
from zerver.decorator import api_key_only_webhook_view
|
2017-09-30 04:18:16 +02:00
|
|
|
from zerver.lib.actions import check_send_stream_message
|
2016-12-02 12:06:20 +01:00
|
|
|
from zerver.lib.response import json_success
|
2017-10-31 04:25:48 +01:00
|
|
|
from zerver.lib.request import REQ, has_request_variables
|
2017-05-02 01:00:50 +02:00
|
|
|
from zerver.models import UserProfile
|
2016-12-02 12:06:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
@api_key_only_webhook_view("Heroku")
|
|
|
|
@has_request_variables
|
2017-05-02 01:00:50 +02:00
|
|
|
def api_heroku_webhook(request, user_profile, stream=REQ(default="heroku"),
|
2016-12-02 12:06:20 +01:00
|
|
|
head=REQ(), app=REQ(), user=REQ(), url=REQ(), git_log=REQ()):
|
2017-05-02 01:00:50 +02:00
|
|
|
# type: (HttpRequest, UserProfile, Text, Text, Text, Text, Text, Text) -> HttpResponse
|
2016-12-02 12:06:20 +01:00
|
|
|
template = "{} deployed version {} of [{}]({})\n> {}"
|
|
|
|
content = template.format(user, head, app, url, git_log)
|
|
|
|
|
2017-09-30 04:18:16 +02:00
|
|
|
check_send_stream_message(user_profile, request.client, stream, app, content)
|
2016-12-02 12:06:20 +01:00
|
|
|
return json_success()
|