locky 5 kuukautta sitten
vanhempi
commit
ebf2fef30e

+ 5 - 1
Object/enums/EventTypeEnum.py

@@ -19,7 +19,7 @@ class EventTypeEnumObj(Enum):
         PRESS_THE_DOORBELL,
         CHILD_PROTECTION_MODE
     ]
-    # 透传推送事件类型列表
+    # 透传推送事件类型列表(音视频通话)
     DATA_PUSH_EVENT_TYPE_LIST = [
         ONE_CLICK_CALL,
         VIDEO_CALL,
@@ -32,3 +32,7 @@ class EventTypeEnumObj(Enum):
         PRESS_THE_DOORBELL,
         SD_CARD_ABNORMALITY
     ]
+    # 系统消息事件类型
+    SYS_MSG_EVENT_TYPE_LIST = [
+        SD_CARD_ABNORMALITY
+    ]

+ 17 - 0
Service/CommonService.py

@@ -18,6 +18,7 @@ from base64 import encodebytes
 
 from AnsjerPush.config import BASE_DIR, ACCESS_KEY_ID, SECRET_ACCESS_KEY, REGION_NAME, PUSH_BUCKET
 from Model.models import iotdeviceInfoModel
+from Object.enums.EventTypeEnum import EventTypeEnumObj
 
 
 # 复用性且公用较高封装代码在这
@@ -422,3 +423,19 @@ GCqvlyw5dfxNA+EtxNE2wCW/LW7ENJlACgcfgPlBZtpLheWoZB/maw4=
         signature = encodebytes(signature).decode('utf8').replace('\n', '')
         # print('signature:', signature)
         return signature
+
+    @staticmethod
+    def get_jump_type(event_type):
+        """
+        获取跳转类型
+        @param event_type: 事件类型
+        @return event_type: 跳转类型,1:推送消息,2:系统消息,3:音视频通话消息
+        """
+        # 跳转类型,1:推送消息,2:系统消息,3:音视频通话消息
+        jump_type = 1
+        event_type = int(event_type)
+        if event_type in EventTypeEnumObj.SYS_MSG_EVENT_TYPE_LIST.value:
+            jump_type = 2
+        elif event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
+            jump_type = 3
+        return jump_type

+ 6 - 1
Service/DevicePushService.py

@@ -705,6 +705,8 @@ class DevicePushService:
         try:
             url = 'https://api.xmpush.xiaomi.com/v3/message/regid'
             app_secret = XMPUSH_CONFIG[appBundleId]
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
             data = {
                 'title': msg_title,
                 'description': msg_text,
@@ -721,6 +723,7 @@ class DevicePushService:
                 'extra.event_type': event_type,
                 'extra.uid': uid,
                 'extra.channel': channel,
+                'jump_type': jump_type
             }
             if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 data['extra.sound_uri'] = 'android.resource://com.ansjer.zccloud_ab/raw/phone_call'
@@ -770,9 +773,11 @@ class DevicePushService:
             result = response.json()
             # 发送推送
             push_url = url + 'server/v1/message/notification/unicast'
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
             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}
+                          'uid': uid, 'channel': channel, 'jump_type': jump_type}
             message = {
                 "target_type": 2,
                 "target_value": token_val,

+ 5 - 1
Service/HuaweiPushService/HuaweiPushService.py

@@ -2,6 +2,7 @@ import json
 
 from AnsjerPush.config import LOGGER
 from Object.enums.EventTypeEnum import EventTypeEnumObj
+from Service.CommonService import CommonService
 from Service.HuaweiPushService import push_admin
 from Service.HuaweiPushService.push_admin import messaging
 
@@ -70,10 +71,13 @@ class HuaweiPushObject:
             image=image_url
         )
 
+        # 跳转类型
+        jump_type = CommonService.get_jump_type(event_type)
         # 自定义键值对
         data = {
             '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
+            'event_type': event_type, 'received_at': n_time, 'event_time': n_time, 'channel': channel,
+            'jump_type': jump_type
         }
         data = json.dumps(data)
         # 推送通知内容配置

+ 19 - 7
Service/PushService.py

@@ -128,9 +128,11 @@ 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)
+            # 跳转类型,1:推送消息,2:系统消息,3:音视频通话消息
+            jump_type = CommonService.get_jump_type(event_type)
             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
+                         'image_url': launch_image, 'jump_type': jump_type
                          }
             sound = 'call_phone.mp3' if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value else 'default'
             payload = apns2.Payload(alert=alert, custom=push_data, sound=sound, category='myCategory',
@@ -207,9 +209,11 @@ class PushObject:
         try:
             event_type = str(event_type)
             n_time = str(n_time)
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
             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
+                         'uid': uid, 'channel': channel, 'jump_type': jump_type
                          }
             if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                 push_data['priority'] = 'high'
@@ -299,9 +303,11 @@ class PushObject:
                 channel_id = '111934'
             else:
                 channel_id = '1'
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
             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
+                         'channel': channel, 'jump_type': jump_type
                          }
             android = jpush.android(title=msg_title, big_text=msg_text, alert=msg_text, extras=push_data,
                                     priority=1, style=1, alert_type=7, channel_id=channel_id
@@ -401,9 +407,11 @@ class PushObject:
             # 鉴权接口调用获得authToken
             sender_send = APISender(app_secret)
             sender_send.set_token(rec['authToken'])
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
             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
+                         'uid': uid, 'channel': channel, 'jump_type': jump_type
                          }
             #  获取唯一标识符
             uid_push_qs = UidPushModel.objects.filter(token_val=token_val).values('m_code')
@@ -533,9 +541,11 @@ 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'
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
             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
+                          'uid': uid, 'channel': channel, 'jump_type': jump_type
                           }
             # 转换为json格式
             extra_data = json.dumps(extra_data)
@@ -609,10 +619,12 @@ 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)}
+            # 跳转类型
+            jump_type = CommonService.get_jump_type(event_type)
             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
+                          'nickname': nickname, 'uid': uid, 'channel': channel, 'title': msg_title, 'body': msg_text,
+                          'jump_type': jump_type
                           }
             # 通知推送
             push_data = {

+ 5 - 1
Service/VSeesHuaweiPushService/VseesHuaweiPushObject.py

@@ -2,6 +2,7 @@ import json
 
 from AnsjerPush.config import LOGGER
 from Object.enums.EventTypeEnum import EventTypeEnumObj
+from Service.CommonService import CommonService
 from Service.VSeesHuaweiPushService import push_admin
 from Service.VSeesHuaweiPushService.push_admin import messaging
 
@@ -70,10 +71,13 @@ class VseesHuaweiPushObject:
             image=image_url
         )
 
+        # 跳转类型
+        jump_type = CommonService.get_jump_type(event_type)
         # 自定义键值对
         data = {
             '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
+            'event_type': event_type, 'received_at': n_time, 'event_time': n_time, 'channel': channel,
+            'jump_type': jump_type
         }
         data = json.dumps(data)
         # 推送通知内容配置