Przeglądaj źródła

优化魅族推送

guanhailong 2 lat temu
rodzic
commit
efeb97e610
2 zmienionych plików z 14 dodań i 17 usunięć
  1. 1 1
      Service/DevicePushService.py
  2. 13 16
      Service/PushService.py

+ 1 - 1
Service/DevicePushService.py

@@ -193,7 +193,7 @@ class DevicePushService:
                     elif push_type == 4:  # android xmpush
                         result['do_xmpush_code'] = cls.do_xmpush(**kwag_args)
                     elif push_type == 5:  # android vivopush
-                        result['do_vivopush_code'] = PushObject.android_meizupush(**kwag_args)
+                        result['do_vivopush_code'] = PushObject.android_vivopush(**kwag_args)
                     elif push_type == 6:  # android oppopush
                         result['do_oppopush_code'] = cls.do_oppopush(**kwag_args)
                     elif push_type == 7:  # android meizupush

+ 13 - 16
Service/PushService.py

@@ -254,17 +254,16 @@ class PushObject:
             return repr(e)
 
     @staticmethod
-    def android_vivopush(app_bundle_id, token_val, n_time, event_type, msg_title, msg_text,
-                         uid='', channel='1', image='', skip_type='1', nickname='', appBundleId=''):
+    def android_vivopush(token_val, n_time, event_type, msg_title, msg_text, app_bundle_id='', uid='', channel='1',
+                         image='', skip_type='1', nickname='', appBundleId=''):
         """
         vivo 推送(不支持图片)
-        @param app_bundle_id: app包id
+        @param app_bundle_id: app包名
+        @param appBundleId: app包名
         @param token_val: 推送token
         @param event_type: 消息类型 (0:运营类消息,1:系统类消息。默认为 0)
         @param msg_title: 推送标题
         @param msg_text: 推送内容
-        @param push_mode: 推送模式 (0:正式推送;1:测试推送,默认为0)
-        @param m_code: 用户请求唯一标识 最大 64 字符
         @param skip_type: 跳转类型(1:打开 APP 首页 2:打开链接 3:自定义 4:打开 app 内指定页面)
         @param n_time: 当前时间
         @param nickname: 设备昵称
@@ -275,13 +274,13 @@ class PushObject:
         """
         logger = logging.getLogger('info')
         try:
+            app_bundle_id = app_bundle_id if app_bundle_id != '' else appBundleId
             authToken = 'authToken_' + app_bundle_id
             redisObj = RedisObject()
             # 获取redis里面的authToken
             redis_authToken = redisObj.get_data(key=authToken)
-            app_bundle_id = app_bundle_id if app_bundle_id == '' else appBundleId
             if msg_title == '':
-                msg_title = '周视'
+                msg_title = APP_BUNDLE_DICT[app_bundle_id]
             if redis_authToken is not False:
                 app_secret = VIVOPUSH_CONFIG[app_bundle_id]['Secret']
                 sender_send = APISender(app_secret)
@@ -302,7 +301,7 @@ class PushObject:
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
                          'uid': uid, 'channel': channel
                          }
-            # 推送
+            # 推送 push_mode: 推送模式 (0:正式推送;1:测试推送,默认为0)
             message = PushMessage() \
                 .reg_id(token_val) \
                 .title(msg_title) \
@@ -387,18 +386,16 @@ class PushObject:
             return repr(e)
 
     @staticmethod
-    def android_meizupush(app_bundle_id, token_val, n_time, event_type, msg_title, msg_text, nickname,
-                          uid='', channel='1', appBundleId='', image=''):
+    def android_meizupush(token_val, n_time, event_type, msg_title, msg_text, uid='', channel='1',
+                          app_bundle_id='', appBundleId='', nickname='', image=''):
         """
         android 魅族推送(不支持图片)
-        @param app_bundle_id: app包id
+        @param app_bundle_id: app包名
+        @param appBundleId: app包名
         @param token_val: 推送token
         @param event_type: 消息类型 (0:运营类消息,1:系统类消息。默认为 0)
         @param msg_title: 推送标题
         @param msg_text: 推送内容
-        @param push_mode: 推送模式 (0:正式推送;1:测试推送,默认为0)
-        @param m_code: 用户请求唯一标识 最大 64 字符
-        @param skip_type: 跳转类型(1:打开 APP 首页 2:打开链接 3:自定义 4:打开 app 内指定页面)
         @param n_time: 当前时间
         @param nickname: 设备昵称
         @param uid: uid
@@ -409,7 +406,7 @@ class PushObject:
         logger = logging.getLogger('info')
         try:
             #  获取包和AppSecret
-            app_bundle_id = app_bundle_id if app_bundle_id == '' else appBundleId
+            app_bundle_id = app_bundle_id if app_bundle_id != '' else appBundleId
             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'
@@ -418,7 +415,7 @@ class PushObject:
                          'uid': uid, 'channel': channel
                          }
             if msg_title == '':
-                msg_title = '周视'
+                msg_title = APP_BUNDLE_DICT[app_bundle_id]
             # 拼接发送内容
             messageJson = '{"clickTypeInfo":{"activity":"","clickType":0,"customAttribute":""},"extra":{},'
             noticeBarInfo = ('"noticeBarInfo": {"title": "%s", "content":  "%s"},' % (msg_title, msg_text))