mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Annotate webhooks/transifex.py, webhooks/yo.py.
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user