Kaynağa Gözat

添加测试苹果推送

lang 3 yıl önce
ebeveyn
işleme
013cb7901b
2 değiştirilmiş dosya ile 21 ekleme ve 0 silme
  1. 4 0
      AnsjerPush/urls.py
  2. 17 0
      Controller/DetectControllerV2.py

+ 4 - 0
AnsjerPush/urls.py

@@ -16,6 +16,7 @@ Including another URLconf
 from django.contrib import admin
 from django.urls import path
 from Controller import DetectController, ShadowController, TestDetectController, EquipmentInfo, DetectControllerV2
+from django.conf.urls import url
 
 urlpatterns = [
     path('admin/', admin.site.urls),
@@ -27,4 +28,7 @@ urlpatterns = [
     path('test/notify/push', TestDetectController.NotificationView.as_view()),
     path('eq/del', EquipmentInfo.deleteExpireEquipmentInfo),
     path('push/healthCheck', EquipmentInfo.healthCheck),
+    path('notifyV2/push', DetectControllerV2.NotificationView.as_view()),
+    url(r'^notifyV2/(?P<operation>.*)$', DetectControllerV2.NotificationView.as_view()),
+
 ]

+ 17 - 0
Controller/DetectControllerV2.py

@@ -50,6 +50,9 @@ class NotificationView(View):
 
     def post(self, request, *args, **kwargs):
         request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        if operation == 'test_apns':
+            return self.test_apns(request.POST)
         return self.validation(request.POST)
 
     def validation(self, request_dict):
@@ -300,6 +303,20 @@ class NotificationView(View):
             logger.info('错误行号', e.__traceback__.tb_lineno)
             return JsonResponse(status=500)
 
+    def test_apns(self,request_dict):
+        kwag_args = {
+            'uid': request_dict.get('uid', None),
+            'channel': request_dict.get('channel', None),
+            'event_type': request_dict.get('event_type', None),
+            'n_time': request_dict.get('n_time', None),
+            'appBundleId':request_dict.get('appBundleId', None),
+            'token_val':request_dict.get('token_val', None),
+            'msg_title':request_dict.get('msg_title', None),
+            'msg_text':request_dict.get('msg_text', None),
+        }
+        do_apns_code = self.do_apns(**kwag_args)
+        return JsonResponse(status=500,data={'do_apns_code':do_apns_code})
+
     def get_msg_title(self, appBundleId, nickname):
         package_title_config = {
             'com.ansjer.customizedd_a': 'DVS',