浏览代码

oppo推送

peng 2 年之前
父节点
当前提交
24ef71e087

+ 2 - 0
Controller/AiController.py

@@ -187,6 +187,8 @@ class AiView(View):
                         PushObject.android_xmpush(**kwargs)
                     elif push_type == 5:  # android vivo推送
                         PushObject.android_vivopush(**kwargs)
+                    elif push_type == 6:  # android oppo推送
+                        PushObject.android_oppopush(**kwargs)
                     elif push_type == 7:  # android 魅族推送
                         PushObject.android_meizupush(**kwargs)
                 except Exception as e:

+ 3 - 0
Controller/ComboCron/ComboCronPushController.py

@@ -235,6 +235,9 @@ class ComboCronPushView(View):
             # android vivo推送
             elif push_type == 5:
                 PushObject.android_vivopush(**kwargs)
+            # android oppo推送
+            elif push_type == 6:
+                PushObject.android_oppopush(**kwargs)
             # android 魅族推送
             elif push_type == 7:
                 PushObject.android_meizupush(**kwargs)

+ 2 - 0
Controller/PowerWarningController.py

@@ -95,6 +95,8 @@ class PowerWarningView(View):
                         PushObject.android_xmpush(**kwargs)
                     elif push_type == 5:  # android vivo推送
                         PushObject.android_vivopush(**kwargs)
+                    elif push_type == 6:  # android oppo推送
+                        PushObject.android_oppopush(**kwargs)
                     elif push_type == 7:  # android 魅族推送
                         PushObject.android_meizupush(**kwargs)
                 except Exception as e:

+ 11 - 2
Controller/gatewayController.py

@@ -177,6 +177,8 @@ class GatewayView(View):
                             PushObject.android_xmpush(**kwargs)
                         elif push_type == 5:  # android vivo推送
                             PushObject.android_vivopush(**kwargs)
+                        elif push_type == 6:  # android oppo推送
+                            PushObject.android_oppopush(**kwargs)
                         elif push_type == 7:  # android 魅族推送
                             PushObject.android_meizupush(**kwargs)
                     except Exception as e:
@@ -210,13 +212,18 @@ class GatewayView(View):
         if not smart_scene_qs.exists():
             return response.json(173)
 
-        nickname = ''
         scene_name = smart_scene_qs[0]['scene_name']
         tasks = smart_scene_qs[0]['tasks']
         device_id = smart_scene_qs[0]['device_id']
         sub_device_id = smart_scene_qs[0]['sub_device_id']
         n_time = int(time.time())
         user_id = smart_scene_qs[0]['user_id']
+        if sub_device_id:
+            gateway_sub_device_qs = GatewaySubDevice.objects.filter(id=sub_device_id).values('nickname')
+            nickname = gateway_sub_device_qs[0]['nickname'] if gateway_sub_device_qs.exists() else ''
+        else:
+            device_qs = Device_Info.objects.filter(id=device_id).values('NickName')
+            nickname = device_qs[0]['NickName'] if device_qs.exists() else ''
         log_dict = {
             'scene_id': scene_id,
             'scene_name': scene_name,
@@ -251,7 +258,7 @@ class GatewayView(View):
                         push_type = gateway_push['push_type']
                         token_val = gateway_push['token_val']
 
-                        kwargs['msg_title'] = nickname
+                        kwargs['msg_title'] = PushObject.get_msg_title(app_bundle_id, nickname)
                         kwargs['msg_text'] = event_info
                         kwargs['app_bundle_id'] = app_bundle_id
                         kwargs['token_val'] = token_val
@@ -268,6 +275,8 @@ class GatewayView(View):
                                 PushObject.android_xmpush(**kwargs)
                             elif push_type == 5:  # android vivo推送
                                 PushObject.android_vivopush(**kwargs)
+                            elif push_type == 6:  # android oppo推送
+                                PushObject.android_oppopush(**kwargs)
                             elif push_type == 7:  # android 魅族推送
                                 PushObject.android_meizupush(**kwargs)
                         except Exception as e:

+ 5 - 13
Service/DevicePushService.py

@@ -167,7 +167,7 @@ class DevicePushService:
         try:
             kwag_args = param['kwag_args']
             result = {'do_apns_code': '', 'do_fcm_code': '', 'do_jpush_code': '', 'do_xmpush_code': '',
-                      'do_vivopush_code': '', 'do_meizupush_code': ''}
+                      'do_vivopush_code': '', 'do_meizupush_code': '', 'do_oppopush_code': ''}
             # 判断是否进行APP消息推送,如app_push不为空,则不进行推送
             if not param['app_push']:
                 LOGGING.info('APP准备推送:{}, {}'.format(param['uid'], param))
@@ -428,9 +428,9 @@ class DevicePushService:
         result = response.json()
         # 发送推送
         push_url = url + 'server/v1/message/notification/unicast'
-        push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
-                     'received_at': n_time, 'event_time': n_time, 'event_type': event_type,
-                     'uid': uid, 'channel': channel}
+        extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+                      'received_at': n_time, 'event_time': n_time, 'event_type': event_type,
+                      'uid': uid, 'channel': channel}
         message = {
             "target_type": 2,
             "target_value": token_val,
@@ -472,15 +472,7 @@ class DevicePushService:
             elif push_type == 4:
                 PushObject.android_xmpush(uid, appBundleId, token_val, n_time, event_type, msg_title,
                                           msg_text, uid, channel, image_url)
-            elif push_type == 5:
-                PushObject.android_meizupush(uid, appBundleId, token_val, n_time, event_type, msg_title,
-                                            msg_text, uid, channel, image_url)
-            elif push_type == 6:
-                PushObject.android_oppopush(uid, appBundleId, token_val, n_time, event_type, msg_title,
-                                            msg_text, uid, channel, image_url)
-            elif push_type == 7:
-                PushObject.android_meizupush(uid, appBundleId, token_val, n_time, event_type, msg_title,
-                                            msg_text, uid, channel, image_url)
+
         except Exception as e:
             LOGGING.info('异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
 

+ 1 - 1
Service/PushService.py

@@ -363,7 +363,7 @@ class PushObject:
             result = response.json()
             # 发送推送
             push_url = url + 'server/v1/message/notification/unicast'
-            push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
+            extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
                          'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
                          'uid': uid, 'channel': channel
                          }