mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	Include a rest_dispatch in tornadoviews and call it from urls.py
(imported from commit aefe66b44be60b39d0f6bb3076502e964f1ed6bd)
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
from __future__ import absolute_import
 | 
			
		||||
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
from django.views.decorators.csrf import csrf_exempt
 | 
			
		||||
from zerver.models import get_client
 | 
			
		||||
 | 
			
		||||
from zerver.decorator import asynchronous, authenticated_api_view, \
 | 
			
		||||
@@ -21,6 +22,9 @@ from zerver.lib.event_queue import allocate_client_descriptor, get_client_descri
 | 
			
		||||
import ujson
 | 
			
		||||
import socket
 | 
			
		||||
 | 
			
		||||
from zerver.lib.rest import rest_dispatch as _rest_dispatch
 | 
			
		||||
rest_dispatch = csrf_exempt((lambda request, *args, **kwargs: _rest_dispatch(request, globals(), *args, **kwargs)))
 | 
			
		||||
 | 
			
		||||
@internal_notify_view
 | 
			
		||||
def notify(request):
 | 
			
		||||
    process_notification(ujson.loads(request.POST['data']))
 | 
			
		||||
 
 | 
			
		||||
@@ -89,9 +89,6 @@ import logging
 | 
			
		||||
from os import path
 | 
			
		||||
from collections import defaultdict
 | 
			
		||||
 | 
			
		||||
# Import the Tornado REST views that are used by rest_dispatch
 | 
			
		||||
from zerver.tornadoviews import get_events_backend, get_updates_backend
 | 
			
		||||
 | 
			
		||||
from zerver.lib.rest import rest_dispatch as _rest_dispatch
 | 
			
		||||
rest_dispatch = csrf_exempt((lambda request, *args, **kwargs: _rest_dispatch(request, globals(), *args, **kwargs)))
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -207,11 +207,12 @@ v1_api_and_json_patterns = patterns('zerver.views',
 | 
			
		||||
            {'PATCH': 'patch_bot_backend'}),
 | 
			
		||||
    url(r'^register$', 'rest_dispatch',
 | 
			
		||||
            {'POST': 'api_events_register'}),
 | 
			
		||||
 | 
			
		||||
) + patterns('zerver.tornadoviews',
 | 
			
		||||
    url(r'^messages/latest$', 'rest_dispatch',
 | 
			
		||||
        {'GET': 'get_updates_backend'}),
 | 
			
		||||
    url(r'^events$', 'rest_dispatch',
 | 
			
		||||
        {'GET': 'get_events_backend'}),
 | 
			
		||||
 | 
			
		||||
)
 | 
			
		||||
if not settings.LOCALSERVER:
 | 
			
		||||
    v1_api_and_json_patterns += patterns('',
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user