Explorar o código

配置小米推送通知类别id

locky hai 1 ano
pai
achega
6beb94d7f6

+ 8 - 0
AnsjerPush/config.py

@@ -179,3 +179,11 @@ EVENT_DICT = {
     69: 'Flame detected ',
     70: 'Face obscured'
 }
+
+# 小米推送通知类别id
+XM_PUSH_CHANNEL_ID = {
+    'push_to_talk': 111934,        # 一键通话
+    'device_reminder': 104551,     # 设备提醒
+    'service_reminder': 104552,    # 服务提醒
+    'sys_notification': 104553     # 系统通知
+}

+ 2 - 1
Controller/ComboCron/ComboCronPushController.py

@@ -18,6 +18,7 @@ from Object.AliyunSmsObject import AliyunSmsObject
 from Object.ResponseObject import ResponseObject
 from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
 from Service.PushService import PushObject
+from AnsjerPush.config import XM_PUSH_CHANNEL_ID
 
 
 class ComboCronPushView(View):
@@ -235,7 +236,7 @@ class ComboCronPushView(View):
                 huawei_push_object.send_push_notify_message(**kwargs)
             # android 小米推送
             elif push_type == 4:
-                channel_id = 104552
+                channel_id = XM_PUSH_CHANNEL_ID['service_reminder']
                 PushObject.android_xmpush(channel_id=channel_id, **kwargs)
             # android vivo推送
             elif push_type == 5:

+ 2 - 1
Controller/PowerWarningController.py

@@ -14,6 +14,7 @@ from Model.models import UidPushModel, SysMsgModel, Device_Info
 from Object.RedisObject import RedisObject
 from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
 from Service.PushService import PushObject
+from AnsjerPush.config import XM_PUSH_CHANNEL_ID
 
 
 class PowerWarningView(View):
@@ -97,7 +98,7 @@ class PowerWarningView(View):
                         huawei_push_object = HuaweiPushObject()
                         huawei_push_object.send_push_notify_message(**kwargs)
                     elif push_type == 4:  # android 小米推送
-                        channel_id = 104551
+                        channel_id = XM_PUSH_CHANNEL_ID['device_reminder']
                         PushObject.android_xmpush(channel_id=channel_id, **kwargs)
                     elif push_type == 5:  # android vivo推送
                         PushObject.android_vivopush(**kwargs)

+ 2 - 2
Controller/gatewayController.py

@@ -9,7 +9,7 @@ import time
 from django.views.generic.base import View
 
 from AnsjerPush.Config.gatewaySensorConfig import SENSOR_TYPE, EVENT_TYPE
-from AnsjerPush.config import LOGGER
+from AnsjerPush.config import LOGGER, XM_PUSH_CHANNEL_ID
 from Model.models import SensorRecord, GatewaySubDevice, GatewayPush, Device_Info, SceneLog, SmartScene, CountryModel
 from Object.ResponseObject import ResponseObject
 from Service.EquipmentInfoService import EquipmentInfoService
@@ -376,7 +376,7 @@ class GatewayView(View):
             huawei_push_object = HuaweiPushObject()
             huawei_push_object.send_push_notify_message(**kwargs)
         elif push_type == 4:  # android 小米推送
-            channel_id = 104551
+            channel_id = XM_PUSH_CHANNEL_ID['device_reminder']
             PushObject.android_xmpush(channel_id=channel_id, **kwargs)
         elif push_type == 5:  # android vivo推送
             PushObject.android_vivopush(**kwargs)

+ 2 - 1
Service/CustomizedPushService.py

@@ -8,6 +8,7 @@ from Model.models import DeviceTypeModel, Device_Info, GatewayPush, CountryModel
 from Service.CommonService import CommonService
 from Service.HuaweiPushService.HuaweiPushService import HuaweiPushObject
 from Service.PushService import PushObject
+from AnsjerPush.config import XM_PUSH_CHANNEL_ID
 CUSTOMIZED_PUSH_LOGGER = logging.getLogger('customized_push')
 
 
@@ -137,7 +138,7 @@ class CustomizedPushObject:
             return huawei_push_object.send_push_notify_message(**push_kwargs)
         # 小米
         elif push_type == 4:
-            push_kwargs['channel_id'] = 104551
+            push_kwargs['channel_id'] = XM_PUSH_CHANNEL_ID['service_reminder']
             return PushObject.android_xmpush(**push_kwargs)
         # vivo
         elif push_type == 5:

+ 4 - 3
Service/DevicePushService.py

@@ -18,7 +18,7 @@ import requests
 
 from AnsjerPush.Config.aiConfig import DEVICE_EVENT_TYPE, ALGORITHM_COMBO_TYPES
 from AnsjerPush.config import CONFIG_INFO, CONFIG_CN, MULTI_CHANNEL_TYPE_LIST, SYS_EVENT_TYPE_LIST, AWS_ACCESS_KEY_ID, \
-    AWS_SECRET_ACCESS_KEY, EVENT_DICT, EVENT_DICT_CN
+    AWS_SECRET_ACCESS_KEY, EVENT_DICT, EVENT_DICT_CN, XM_PUSH_CHANNEL_ID
 from AnsjerPush.config import XMPUSH_CONFIG, OPPOPUSH_CONFIG
 from Model.models import UidPushModel, SysMsgModel, DeviceSharePermission, DeviceChannelUserSet, \
     DeviceChannelUserPermission, UidSetModel, Device_Info
@@ -331,9 +331,10 @@ class DevicePushService:
                     huawei_push_object.send_push_notify_message(**push_kwargs)
                 elif push_type == 4:  # android xmpush
                     if param['event_type'] in [606, 607]:
-                        channel_id = 111934
+                        push_channel = 'push_to_talk'
                     else:
-                        channel_id = 104551
+                        push_channel = 'device_reminder'
+                    channel_id = XM_PUSH_CHANNEL_ID[push_channel]
                     cls.do_xmpush(channel_id=channel_id, **push_kwargs)
                     push_result = True
                 elif push_type == 5:  # android vivopush