소스 검색

vivo/oppo推送,极光透传

peng 2 년 전
부모
커밋
e517ceb522
2개의 변경된 파일27개의 추가작업 그리고 26개의 파일을 삭제
  1. 1 24
      Service/DevicePushService.py
  2. 26 2
      Service/PushService.py

+ 1 - 24
Service/DevicePushService.py

@@ -679,7 +679,7 @@ class DevicePushService:
         if response.status_code == 200:
             LOGGING.info("oppo推送返回值:{},uid:{},time:{},event:{}".format(response.json(), uid, now_time, event_type))
             if event_type == 606 or event_type == '606':
-                DevicePushService.jpush_transparent_transmission(msg_title, msg_text, appBundleId, jg_token_val)
+                PushObject.jpush_transparent_transmission(msg_title, msg_text, appBundleId, jg_token_val)
             return response.json()
 
     @classmethod
@@ -924,26 +924,3 @@ class DevicePushService:
         week = LocalDateTimeUtil.date_to_week(now_data)
         return now_data, week
 
-    @staticmethod
-    def jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, token_val):
-        """
-        android 极光透传
-        @param msg_title: 推送标题
-        @param msg_text: 推送内容
-        @param token_val: 推送token
-        @param app_bundle_id: app包id
-        @return: None
-        """
-        try:
-            app_key = JPUSH_CONFIG[app_bundle_id]['Key']
-            master_secret = JPUSH_CONFIG[app_bundle_id]['Secret']
-            # 换成各自的app_key和master_secret
-            _jpush = jpush.JPush(app_key, master_secret)
-            push = _jpush.create_push()
-            push.audience = jpush.registration_id(token_val)
-            push.message = jpush.message(msg_content=msg_text, title=msg_title)
-            push.platform = jpush.all_
-            res = push.send()
-            assert res.status_code == 200
-        except Exception as e:
-            return repr(e)

+ 26 - 2
Service/PushService.py

@@ -326,7 +326,7 @@ class PushObject:
             rec = sender_send.send(message)
             logger.info('vivo推送结果:{}, 设备uid:{}'.format(rec, uid))
             if rec['result'] == 0 and (event_type == 606 or event_type == '606'):
-                DevicePushService.jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, jg_token_val)
+                PushObject.jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, jg_token_val)
             return rec
         except Exception as e:
             logger.info('vivo推送异常:{}'.format(e))
@@ -401,7 +401,7 @@ class PushObject:
             response = requests.post(push_url, data=push_data, headers=headers)
             logger.info("oppo推送返回值:{}".format(response.json()))
             if response.status_code == 200 and (event_type == 606 or event_type == '606'):
-                DevicePushService.jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, jg_token_val)
+                PushObject.jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, jg_token_val)
         except Exception as e:
             return repr(e)
 
@@ -466,3 +466,27 @@ class PushObject:
             return response.status_code
         except Exception as e:
             return repr(e)
+
+    @staticmethod
+    def jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, token_val):
+        """
+        android 极光透传
+        @param msg_title: 推送标题
+        @param msg_text: 推送内容
+        @param token_val: 推送token
+        @param app_bundle_id: app包id
+        @return: None
+        """
+        try:
+            app_key = JPUSH_CONFIG[app_bundle_id]['Key']
+            master_secret = JPUSH_CONFIG[app_bundle_id]['Secret']
+            # 换成各自的app_key和master_secret
+            _jpush = jpush.JPush(app_key, master_secret)
+            push = _jpush.create_push()
+            push.audience = jpush.registration_id(token_val)
+            push.message = jpush.message(msg_content=msg_text, title=msg_title)
+            push.platform = jpush.all_
+            res = push.send()
+            assert res.status_code == 200
+        except Exception as e:
+            return repr(e)