mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Move flushing the display recipient cache to its own middleware
(imported from commit 27a6935a5830ef986b18de169d66dd86d273d064)
This commit is contained in:
		@@ -48,11 +48,6 @@ class LogRequests(object):
 | 
			
		||||
                return "%.1fs" % (timedelta)
 | 
			
		||||
            return "%.0fms" % (timedelta_ms(timedelta),)
 | 
			
		||||
 | 
			
		||||
        # We flush the recipient cache after every request, so it is
 | 
			
		||||
        # not shared at all between requests. We do this so all users
 | 
			
		||||
        # have a consistent view of stream name changes.
 | 
			
		||||
        flush_per_process_display_recipient_cache()
 | 
			
		||||
 | 
			
		||||
        # For statsd timer name
 | 
			
		||||
        if request.path == '/':
 | 
			
		||||
            statsd_path = 'webreq'
 | 
			
		||||
@@ -216,3 +211,11 @@ class RateLimitMiddleware(object):
 | 
			
		||||
        if type(exception) == RateLimited:
 | 
			
		||||
            resp = json_error("API usage exceeded rate limit, try again in %s secs" % (request._ratelimit_secs_to_freedom,), status=403)
 | 
			
		||||
            return resp
 | 
			
		||||
 | 
			
		||||
class FlushDisplayRecipientCache(object):
 | 
			
		||||
    def process_response(self, request, response):
 | 
			
		||||
        # We flush the recipient cache after every request, so it is
 | 
			
		||||
        # not shared at all between requests. We do this so all users
 | 
			
		||||
        # have a consistent view of stream name changes.
 | 
			
		||||
        flush_per_process_display_recipient_cache()
 | 
			
		||||
        return response
 | 
			
		||||
 
 | 
			
		||||
@@ -156,6 +156,7 @@ MIDDLEWARE_CLASSES = (
 | 
			
		||||
    'zerver.middleware.LogRequests',
 | 
			
		||||
    'zerver.middleware.JsonErrorHandler',
 | 
			
		||||
    'zerver.middleware.RateLimitMiddleware',
 | 
			
		||||
    'zerver.middleware.FlushDisplayRecipientCache',
 | 
			
		||||
    'django.middleware.common.CommonMiddleware',
 | 
			
		||||
    'django.contrib.sessions.middleware.SessionMiddleware',
 | 
			
		||||
    'django.middleware.csrf.CsrfViewMiddleware',
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user