2016-12-02 12:06:20 +01:00
|
|
|
# Webhooks for external integrations.
|
|
|
|
from typing import Text
|
|
|
|
|
|
|
|
from django.http import HttpRequest, HttpResponse
|
|
|
|
|
|
|
|
from zerver.lib.actions import check_send_message
|
|
|
|
from zerver.lib.response import json_success
|
|
|
|
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
|
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-05-02 01:00:50 +02:00
|
|
|
check_send_message(user_profile, request.client, "stream", [stream], app, content)
|
2016-12-02 12:06:20 +01:00
|
|
|
return json_success()
|