瀏覽代碼

Merge branch 'test' of http://192.168.136.99:3000/servers/ASJPush into locky

 Conflicts:
	AnsjerPush/test_config/test_config.py
locky 7 月之前
父節點
當前提交
93fd196302

+ 17 - 0
AnsjerPush/config.py

@@ -222,6 +222,23 @@ XM_PUSH_CHANNEL_ID = {
     'single_login': 126707  # 单点登录
 }
 
+XM_PUSH_CHANNEL_DICT = {
+    'com.ansjer.zccloud_ab': {
+        'push_to_talk': 111934,  # 一键通话
+        'device_reminder': 104551,  # 设备提醒
+        'service_reminder': 104552,  # 服务提醒
+        'sys_notification': 104553,  # 系统通知
+        'single_login': 126707  # 单点登录
+    },
+    'com.cloudlife.commissionf_a': {
+        'push_to_talk': 131636,  # 一键通话
+        'device_reminder': 131638,  # 设备提醒
+        'service_reminder': 131640,  # 服务提醒
+        'sys_notification': 131639,  # 系统通知
+        'single_login': 131637  # 单点登录
+    }
+}
+
 firebase_admin.initialize_app(credentials.Certificate(
     BASE_DIR + '/static/fcm/adcloud-fdf9b-firebase-adminsdk-dcvn1-d53e047cc8.json'))
 

+ 11 - 0
AnsjerPush/test_config/test_config.py

@@ -199,3 +199,14 @@ HONORPUSH_CONFIG = {
         'app_id': 104481203
     }
 }
+
+HUAWEI_CONFIG = {
+    'com.ansjer.zccloud_ab': {
+        'app_id': '101064781',
+        'app_secret': '29d5c5367208e35079f14779597b8f6bcc28ee39091546ed577862231fdd0fdd'
+    },
+    'com.cloudlife.commissionf_a': {
+        'app_id': '108703647',
+        'app_secret': '6bc5b0b0ab4588fcd667b3e6c1ab4fd5d857de21ad69ee9d46e077b9f5f24e8f'
+    }
+}

+ 11 - 6
Service/DevicePushService.py

@@ -23,7 +23,7 @@ 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, CONFIG_TEST, HUAWEICLOUD_AK, HUAWEICLOUD_SK, \
     HUAWEICLOUD_OBS_SERVER, HUAWEICLOUD_PUSH_BUKET, OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET
-from AnsjerPush.config import XMPUSH_CONFIG, OPPOPUSH_CONFIG, XM_PUSH_CHANNEL_ID
+from AnsjerPush.config import XMPUSH_CONFIG, OPPOPUSH_CONFIG, XM_PUSH_CHANNEL_ID, XM_PUSH_CHANNEL_DICT
 from Model.models import UidPushModel, SysMsgModel, DeviceSharePermission, DeviceChannelUserSet, \
     DeviceChannelUserPermission, UidSetModel, Device_Info, UserAudioVideoPush, PushLog
 from Object.ETkObject import ETkObject
@@ -418,8 +418,7 @@ class DevicePushService:
                 # thread_pool.submit(cls.async_send_picture_push, (
                 #     push_type, kwargs['aws_s3_client'], kwargs['bucket'], key,
                 #     kwargs['uid'], kwargs['appBundleId'], kwargs['token_val'], kwargs['event_type'], kwargs['n_time'],
-                #     push_kwargs['msg_title'], push_kwargs['msg_text'], kwargs['channel'], kwargs['storage_location']))
-
+                #     push_kwargs['msg_title'], push_kwargs['msg_text'], kwargs['channel'], kwargs['storage_location'])
                 push_thread = threading.Thread(target=cls.async_send_picture_push, args=(
                     push_type, kwargs['aws_s3_client'], kwargs['bucket'], key,
                     kwargs['uid'], kwargs['appBundleId'], kwargs['token_val'], kwargs['event_type'], kwargs['n_time'],
@@ -453,14 +452,17 @@ class DevicePushService:
                         push_result = PushObject.android_jpush(**kwargs)
 
                 elif push_type == 3:
-                    huawei_push_object = HuaweiPushObject()
+                    if kwargs["app_bundle_id"]:
+                        huawei_push_object = HuaweiPushObject(appBundleId=kwargs["app_bundle_id"])
+                    else:
+                        huawei_push_object = HuaweiPushObject()
                     huawei_push_object.send_push_notify_message(**push_kwargs)
                 elif push_type == 4:  # android xmpush
                     if kwargs['event_type'] in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                         push_channel = 'push_to_talk'
                     else:
                         push_channel = 'device_reminder'
-                    channel_id = XM_PUSH_CHANNEL_ID[push_channel]
+                    channel_id = XM_PUSH_CHANNEL_DICT[kwargs['appBundleId']][push_channel]
                     push_result = cls.do_xmpush(channel_id=channel_id, **push_kwargs)
                 elif push_type == 5:  # android vivopush
                     push_result = PushObject.android_vivopush(**push_kwargs)
@@ -795,7 +797,10 @@ class DevicePushService:
                 push_result = PushObject.android_fcm_push_v1(
                     uid, appBundleId, token_val, n_time, event_type, msg_title, msg_text, uid, channel, image_url)
             elif push_type == 3:
-                huawei_push_object = HuaweiPushObject()
+                if appBundleId:
+                    huawei_push_object = HuaweiPushObject(appBundleId=appBundleId)
+                else:
+                    huawei_push_object = HuaweiPushObject()
                 push_result = huawei_push_object.send_push_notify_message(
                     token_val=token_val, msg_title=msg_title, msg_text=msg_text, uid=uid, event_type=event_type,
                     n_time=n_time, image_url=image_url, channel=channel)

+ 4 - 4
Service/HuaweiPushService/HuaweiPushService.py

@@ -4,14 +4,14 @@ from AnsjerPush.config import LOGGER
 from Object.enums.EventTypeEnum import EventTypeEnumObj
 from Service.HuaweiPushService import push_admin
 from Service.HuaweiPushService.push_admin import messaging
-
+from AnsjerPush.config import HUAWEI_CONFIG
 
 class HuaweiPushObject:
     # 华为推送服务类
 
-    def __init__(self):
-        self.app_id = '101064781'
-        self.app_secret = '29d5c5367208e35079f14779597b8f6bcc28ee39091546ed577862231fdd0fdd'
+    def __init__(self, appBundleId='com.ansjer.zccloud_ab'):
+        self.app_id = HUAWEI_CONFIG[appBundleId]['app_id']
+        self.app_secret = HUAWEI_CONFIG[appBundleId]['app_secret']
         self.init_app()
 
     def init_app(self):