Procházet zdrojové kódy

push type = 1 透传

chenjunkai před 6 roky
rodič
revize
f2f2a86bd9

+ 0 - 40
Ansjer/test/util/jpush.py

@@ -1,40 +0,0 @@
-#!/usr/bin/env python3  
-# -*- coding: utf-8 -*-  
-"""
-@Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
-@AUTHOR: ASJRD018
-@NAME: AnsjerFormal
-@software: PyCharm
-@DATE: 2019/3/6 17:43
-@Version: python3.6
-@MODIFY DECORD:ansjer dev
-@file: jpush.py
-@Contact: chanjunkai@163.com
-"""
-import apns2
-import time
-
-now_time = int(time.time())
-
-# cli = apns2.APNSClient(mode="dev", client_cert="/your/path.pem")
-# alert = apns2.PayloadAlert(body="body!", title="title!")
-# payload = apns2.Payload(alert=alert)
-# n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
-# response = cli.push(n=n, device_token="your_token")
-# assert response.status_code == 200, response.reason
-# assert response.apns_id
-import json
-
-token_val = 'ce10ecef7e78775b4100377e851e38b1687cb8df64b2a13ef32857df035a202a'
-# cli = apns2.APNSClient(mode="prod", client_cert=pem_path)
-pem_path = 'D:/13.56.215.252/git/AnsjerFormal/Ansjer/file/apns_pem/apns-dev-test.pem'
-cli = apns2.APNSClient(mode="dev", client_cert=pem_path, password='111111')
-push_data = {"alert": "Motion ", "event_time": now_time, "event_type": '51', "msg": "",
-             "received_at": now_time, "sound": "sound.aif", "uid": "XFDJUHUIOKJHYTGSFFDR"}
-alert = apns2.PayloadAlert(body=json.dumps(push_data), title="title!")
-payload = apns2.Payload(alert=alert)
-
-n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
-res = cli.push(n=n, device_token=token_val, topic='com.ansjer.loocamccloud')
-from var_dump import var_dump
-var_dump(res)

+ 0 - 30
Ansjer/test/util/spnsss.py

@@ -1,30 +0,0 @@
-#coding=utf-8
-import threading
-from time import sleep,ctime
-
-def sing():
-    for i in range(3):
-        print("正在唱歌...%d"%i)
-        sleep(1)
-
-def dance():
-    for i in range(3):
-        print("正在跳舞...%d"%i)
-        sleep(1)
-
-if __name__ == '__main__':
-    print('---开始---:%s'%ctime())
-
-    t1 = threading.Thread(target=sing)
-    t2 = threading.Thread(target=dance)
-
-    t1.start()
-    t2.start()
-
-    while True:
-        length = len(threading.enumerate())
-        print('当前运行的线程数为:%d'%length)
-        if length<=1:
-            break
-
-        sleep(0.5)

+ 1 - 0
Controller/AccessLog.py

@@ -207,6 +207,7 @@ def deleteSn(request):
     own_perm = ModelService.check_perm(userID, 10)
     if own_perm is not True:
         return response.json(404)
+
     dltime = datetime.datetime.now() - datetime.timedelta(days=int(days))
     count = Access_Log.objects.filter(time__gte=dltime).delete()
     return response.json(0, count)

+ 5 - 2
Controller/Test.py

@@ -40,7 +40,8 @@ class Test(View):
         test_push_type = request_dict.get('test_push_type')
         if test_push_type == 'jpush':
             return self.jgPush(request)
-        return self.do_fcm_push(request)
+        elif test_push_type == 'fcm':
+            return self.do_fcm_push(request)
         return self.do_gcm_push(request)
         return self.do_alipay_query_status()
 
@@ -99,7 +100,9 @@ class Test(View):
         message_body = '警告:Motion Channel:1 日期:{tt}'.format(
             tt=str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))))
         print(message_body)
-        if push_type:
+        if push_type == '1':
+            result = push_service.single_device_data_message(registration_id=registration_id, data_message=data)
+        elif push_type == '2':
             result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title,
                                                        message_body=message_body, data_message=data,time_to_live=3600)
         else: