Bladeren bron

修改透传消息发送内容

locky 7 maanden geleden
bovenliggende
commit
e9bbf3d5ab

+ 3 - 3
Controller/AiController.py

@@ -590,7 +590,7 @@ class AiView(View):
         _jpush = jpush.JPush(app_key, master_secret)
         push = _jpush.create_push()
         push.audience = jpush.registration_id(token_val)
-        push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
+        push_data = {"alert": msg_text, "event_time": n_time, "event_type": event_type, "msg": "",
                      "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
         android = jpush.android(alert=msg_text, priority=1, style=1, alert_type=7,
                                 big_text=msg_text, title=msg_title,
@@ -606,7 +606,7 @@ class AiView(View):
 
             serverKey = FCM_CONFIG[appBundleId]
             push_service = FCMNotification(api_key=serverKey)
-            data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
+            data = {"alert": msg_text, "event_time": n_time, "event_type": event_type, "msg": "",
                     "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
             result = push_service.notify_single_device(registration_id=token_val, message_title=msg_title,
                                                        message_body=msg_text, data_message=data,
@@ -630,7 +630,7 @@ class AiView(View):
         try:
             cli = apns2.APNSClient(mode=APNS_MODE,
                                    client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
-            push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
+            push_data = {"alert": msg_text, "event_time": n_time, "event_type": event_type, "msg": "",
                          "received_at": n_time, "sound": "", "uid": uid, "zpush": "1", "channel": channel}
             alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
             payload = apns2.Payload(alert=alert, custom=push_data, sound="default")

+ 1 - 1
Controller/TransparentTransmissionPushController.py

@@ -160,7 +160,7 @@ class TransparentTransmissionPushView(View):
             push_url = 'https://push-api.cloud.hihonor.com/api/v1/{}/sendMessage'.format(app_id)
             headers = {'Content-Type': 'application/json', 'Authorization': authorization_token,
                        'timestamp': str(int(time.time()) * 1000)}
-            extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            extra_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                           'received_at': n_time, 'event_time': n_time, 'event_type': str(event_type),
                           'nickname': nickname, 'title': msg_title, 'body': msg_text}
             # 透传推送

+ 3 - 7
Service/DevicePushService.py

@@ -290,7 +290,7 @@ class DevicePushService:
                             'device_uid': params['uid'],
                             'device_nick_name': params['nickname'],
                             'channel': params['channel'],
-                            'alarm': 'Motion \tChannel:{}'.format(params['channel']),
+                            'alarm': '',
                             'is_st': params['is_st'],
                             'add_time': int(time.time()),
                             'storage_location': params['storage_location'],
@@ -673,10 +673,6 @@ class DevicePushService:
         try:
             url = 'https://api.xmpush.xiaomi.com/v3/message/regid'
             app_secret = XMPUSH_CONFIG[appBundleId]
-            # payload = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
-            #            'received_at': n_time, 'event_time': n_time, 'event_type': event_type,
-            #            'uid': uid, 'channel': channel
-            #            }
             data = {
                 'title': msg_title,
                 'description': msg_text,
@@ -684,7 +680,7 @@ class DevicePushService:
                 'restricted_package_name': appBundleId,
                 'registration_id': token_val,
                 'extra.channel_id': channel_id,
-                'extra.alert': 'Motion',
+                'extra.alert': msg_text,
                 'extra.msg': '',
                 'extra.sound': 'sound.aif',
                 'extra.zpush': '1',
@@ -742,7 +738,7 @@ class DevicePushService:
             result = response.json()
             # 发送推送
             push_url = url + 'server/v1/message/notification/unicast'
-            extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            extra_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                           'received_at': n_time, 'event_time': n_time, 'event_type': event_type,
                           'uid': uid, 'channel': channel}
             message = {

+ 1 - 1
Service/HuaweiPushService/HuaweiPushService.py

@@ -72,7 +72,7 @@ class HuaweiPushObject:
 
         # 自定义键值对
         data = {
-            'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': uid, 'nickname': nickname,
+            'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': uid, 'nickname': nickname,
             'event_type': event_type, 'received_at': n_time, 'event_time': n_time, 'channel': channel
         }
         data = json.dumps(data)

+ 9 - 13
Service/PushService.py

@@ -127,7 +127,7 @@ class PushObject:
         try:
             cli = apns2.APNSClient(mode=APNS_MODE, client_cert=pem_path)
             alert = apns2.PayloadAlert(title=msg_title, body=msg_text, launch_image=launch_image)
-            push_data = {'alert': 'Motion', 'msg': '', 'sound': '', 'zpush': '1', 'uid': uid, 'channel': channel,
+            push_data = {'alert': msg_text, 'msg': '', 'sound': '', 'zpush': '1', 'uid': uid, 'channel': channel,
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
                          'image_url': launch_image
                          }
@@ -164,7 +164,7 @@ class PushObject:
         try:
             serverKey = FCM_CONFIG[app_bundle_id]
             push_service = FCMNotification(api_key=serverKey)
-            push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'image': image,
+            push_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'image': image,
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
                          'uid': uid, 'channel': channel
                          }
@@ -206,7 +206,7 @@ class PushObject:
         try:
             event_type = str(event_type)
             n_time = str(n_time)
-            push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            push_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
                          'uid': uid, 'channel': channel
                          }
@@ -257,7 +257,7 @@ class PushObject:
                 channel_id = '111934'
             else:
                 channel_id = '1'
-            push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': nickname,
+            push_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': nickname,
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
                          'channel': channel
                          }
@@ -294,10 +294,6 @@ class PushObject:
         try:
             url = 'https://api.xmpush.xiaomi.com/v3/message/regid'
             app_secret = XMPUSH_CONFIG[app_bundle_id]
-            # payload = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
-            #            'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
-            #            'uid': uid, 'channel': channel
-            #            }
             data = {
                 'title': msg_title,
                 'description': msg_text,
@@ -305,7 +301,7 @@ class PushObject:
                 'restricted_package_name': app_bundle_id,
                 'registration_id': token_val,
                 'extra.channel_id': channel_id,
-                'extra.alert': 'Motion',
+                'extra.alert': msg_text,
                 'extra.msg': '',
                 'extra.sound': 'sound.aif',
                 'extra.zpush': '1',
@@ -362,7 +358,7 @@ class PushObject:
             # 鉴权接口调用获得authToken
             sender_send = APISender(app_secret)
             sender_send.set_token(rec['authToken'])
-            push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'image': image,
+            push_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'image': image,
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
                          'uid': uid, 'channel': channel
                          }
@@ -440,7 +436,7 @@ class PushObject:
             result = response.json()
             # 发送推送
             push_url = url + 'server/v1/message/notification/unicast'
-            extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            extra_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                           'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
                           'uid': uid, 'channel': channel
                           }
@@ -494,7 +490,7 @@ class PushObject:
             appId = MEIZUPUSH_CONFIG[app_bundle_id]['ID']
             appSecret = MEIZUPUSH_CONFIG[app_bundle_id]['AppSecret']
             url = 'https://server-api-push.meizu.com/garcia/api/server/push/varnished/pushByPushId'
-            extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            extra_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                           'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
                           'uid': uid, 'channel': channel
                           }
@@ -570,7 +566,7 @@ class PushObject:
             push_url = 'https://push-api.cloud.hihonor.com/api/v1/{}/sendMessage'.format(app_id)
             headers = {'Content-Type': 'application/json', 'Authorization': authorization_token,
                        'timestamp': str(int(time.time()) * 1000)}
-            extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            extra_data = {'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                           'received_at': n_time, 'event_time': n_time, 'event_type': str(event_type),
                           'nickname': nickname,
                           'uid': uid, 'channel': channel, 'title': msg_title, 'body': msg_text