Browse Source

Vsees华为推送代码

linhaohong 7 months ago
parent
commit
0f9ddc6ff3

+ 11 - 0
AnsjerPush/test_config/test_config.py

@@ -193,4 +193,15 @@ HONORPUSH_CONFIG = {
         'client_secret': '7z8RazyCVmPYx4icpIqYr6KLFnEowkag',
         'client_secret': '7z8RazyCVmPYx4icpIqYr6KLFnEowkag',
         'app_id': 104435107
         'app_id': 104435107
     }
     }
+}
+
+HUAWEI_CONFIG = {
+    'com.ansjer.zccloud_ab': {
+        'app_id': '101064781',
+        'app_secret': '29d5c5367208e35079f14779597b8f6bcc28ee39091546ed577862231fdd0fdd'
+    },
+    'com.cloudlife.commissionf_a': {
+        'app_id': '108703647',
+        'app_secret': '6bc5b0b0ab4588fcd667b3e6c1ab4fd5d857de21ad69ee9d46e077b9f5f24e8f'
+    }
 }
 }

+ 8 - 2
Service/DevicePushService.py

@@ -453,7 +453,10 @@ class DevicePushService:
                         push_result = PushObject.android_jpush(**kwargs)
                         push_result = PushObject.android_jpush(**kwargs)
 
 
                 elif push_type == 3:
                 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)
                     huawei_push_object.send_push_notify_message(**push_kwargs)
                 elif push_type == 4:  # android xmpush
                 elif push_type == 4:  # android xmpush
                     if kwargs['event_type'] in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
                     if kwargs['event_type'] in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
@@ -795,7 +798,10 @@ class DevicePushService:
                 push_result = PushObject.android_fcm_push_v1(
                 push_result = PushObject.android_fcm_push_v1(
                     uid, appBundleId, token_val, n_time, event_type, msg_title, msg_text, uid, channel, image_url)
                     uid, appBundleId, token_val, n_time, event_type, msg_title, msg_text, uid, channel, image_url)
             elif push_type == 3:
             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(
                 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,
                     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)
                     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 Object.enums.EventTypeEnum import EventTypeEnumObj
 from Service.HuaweiPushService import push_admin
 from Service.HuaweiPushService import push_admin
 from Service.HuaweiPushService.push_admin import messaging
 from Service.HuaweiPushService.push_admin import messaging
-
+from AnsjerPush.config import HUAWEI_CONFIG
 
 
 class HuaweiPushObject:
 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()
         self.init_app()
 
 
     def init_app(self):
     def init_app(self):