From 73d783b97d4804729f941a04cc28a2cfa402fc07 Mon Sep 17 00:00:00 2001 From: nineven Date: Sat, 11 Dec 2021 22:22:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/views/receiveudids.py | 35 +------------------------------ 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/fir_ser/api/views/receiveudids.py b/fir_ser/api/views/receiveudids.py index b27e91e..98db069 100644 --- a/fir_ser/api/views/receiveudids.py +++ b/fir_ser/api/views/receiveudids.py @@ -8,7 +8,6 @@ import logging from celery.exceptions import TimeoutError from django.http import HttpResponsePermanentRedirect, FileResponse, HttpResponse from django.views import View -from rest_framework import exceptions from rest_framework.response import Response from rest_framework.views import APIView @@ -25,39 +24,7 @@ from fir_ser.celery import app logger = logging.getLogger(__name__) -class UdidView(View): - throttle_classes = [] - - def check_throttles(self, request): - """ - Check if request should be throttled. - Raises an appropriate exception if the request is throttled. - """ - throttle_durations = [] - for throttle in [throttle() for throttle in self.throttle_classes]: - if not throttle.allow_request(request, self): - throttle_durations.append(throttle.wait()) - - if throttle_durations: - durations = [ - duration for duration in throttle_durations - if duration is not None - ] - - duration = max(durations, default=None) - raise exceptions.Throttled(duration) - - def dispatch(self, request, *args, **kwargs): - try: - self.check_throttles(request) - except Exception as e: - r_url = f"{get_redirect_server_domain(request)}/{kwargs.get('short')}?udid={str(e)}&msg=访问受限制,请稍后再试" - logger.error(f"ip:{get_real_ip_address(request)} short:{kwargs.get('short')} {str(e)}") - return HttpResponsePermanentRedirect(r_url) - return super().dispatch(request, *args, **kwargs) - - -class IosUDIDView(UdidView): +class IosUDIDView(APIView): throttle_classes = [ReceiveUdidThrottle1, ReceiveUdidThrottle2] def post(self, request, short):