mirror of https://github.com/zulip/zulip.git
Annotate webhooks/transifex.py, webhooks/yo.py.
This commit is contained in:
parent
7f0709b65c
commit
8afeb7d8ce
|
@ -1,10 +1,12 @@
|
|||
# Webhooks for external integrations.
|
||||
from __future__ import absolute_import
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from zerver.models import UserProfile, Client
|
||||
from zerver.lib.actions import check_send_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
|
||||
|
||||
from typing import Optional
|
||||
|
||||
@api_key_only_webhook_view('Transifex')
|
||||
@has_request_variables
|
||||
|
@ -13,6 +15,7 @@ def api_transifex_webhook(request, user_profile, client,
|
|||
language=REQ(), translated=REQ(default=None),
|
||||
reviewed=REQ(default=None),
|
||||
stream=REQ(default='transifex')):
|
||||
# type: (HttpRequest, UserProfile, Client, str, str, str, Optional[int], Optional[int], str) -> HttpResponse
|
||||
subject = "{} in {}".format(project, language)
|
||||
if translated:
|
||||
body = "Resource {} fully translated.".format(resource)
|
||||
|
|
|
@ -3,14 +3,18 @@ from __future__ import absolute_import
|
|||
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
|
||||
from zerver.models import UserProfile, Client
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Optional
|
||||
|
||||
import ujson
|
||||
|
||||
@api_key_only_webhook_view('Yo')
|
||||
@has_request_variables
|
||||
def api_yo_app_webhook(request, user_profile, client, email=REQ(default=None),
|
||||
username=REQ(default='Yo Bot'), topic=REQ(default='None'),
|
||||
user_ip=REQ(default='None')):
|
||||
username=REQ(default='Yo Bot'), topic=REQ(default=None),
|
||||
user_ip=REQ(default=None)):
|
||||
# type: (HttpRequest, UserProfile, Client, Optional[str], str, Optional[str], Optional[str]) -> HttpResponse
|
||||
|
||||
body = ('Yo from %s') % (username,)
|
||||
check_send_message(user_profile, client, 'private', [email], topic, body)
|
||||
|
|
Loading…
Reference in New Issue