2016-12-02 12:06:20 +01:00
|
|
|
# Webhooks for external integrations.
|
|
|
|
from django.http import HttpRequest, HttpResponse
|
|
|
|
|
2020-08-20 00:32:15 +02:00
|
|
|
from zerver.decorator import webhook_view
|
2017-11-16 00:43:10 +01:00
|
|
|
from zerver.lib.response import json_success
|
2023-08-12 09:35:14 +02:00
|
|
|
from zerver.lib.typed_endpoint import typed_endpoint
|
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
|
|
|
|
2019-04-12 05:36:17 +02:00
|
|
|
TEMPLATE = """
|
|
|
|
{user} deployed version {head} of [{app}]({url}):
|
|
|
|
|
|
|
|
``` quote
|
|
|
|
{git_log}
|
|
|
|
```
|
|
|
|
""".strip()
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2020-08-20 00:32:15 +02:00
|
|
|
@webhook_view("Heroku", notify_bot_owner_on_invalid_json=False)
|
2023-08-12 09:35:14 +02:00
|
|
|
@typed_endpoint
|
2021-02-12 08:19:30 +01:00
|
|
|
def api_heroku_webhook(
|
|
|
|
request: HttpRequest,
|
|
|
|
user_profile: UserProfile,
|
2023-08-12 09:35:14 +02:00
|
|
|
*,
|
|
|
|
head: str,
|
|
|
|
app: str,
|
|
|
|
user: str,
|
|
|
|
url: str,
|
|
|
|
git_log: str,
|
2021-02-12 08:19:30 +01:00
|
|
|
) -> HttpResponse:
|
|
|
|
content = TEMPLATE.format(user=user, head=head, app=app, url=url, git_log=git_log)
|
2016-12-02 12:06:20 +01:00
|
|
|
|
2018-03-16 22:53:50 +01:00
|
|
|
check_send_webhook_message(request, user_profile, app, content)
|
2022-01-31 13:44:02 +01:00
|
|
|
return json_success(request)
|