Explorar o código

接口增加极光token

peng %!s(int64=2) %!d(string=hai) anos
pai
achega
45adf057c0

+ 5 - 9
Controller/DetectControllerV2.py

@@ -94,7 +94,7 @@ class DetectControllerViewV2(View):
 
     def do_change_status(self, userID, request_dict, response):
         token_val = request_dict.get('token_val', None)
-        jg_token_val = request_dict.get('jg_token_val', None)
+        jg_token_val = request_dict.get('jg_token_val', '')
         appBundleId = request_dict.get('appBundleId', None)
         app_type = request_dict.get('app_type', None)
         push_type = request_dict.get('push_type', None)
@@ -197,7 +197,7 @@ class DetectControllerViewV2(View):
                             'app_type': app_type,
                             'push_type': push_type,
                             'token_val': token_val,
-                            'jg_token_val': jg_token_val if push_type in ['5', '6'] and jg_token_val else '',
+                            'jg_token_val': jg_token_val,
                             'updTime': nowTime,
                             'lang': lang,
                             'tz': tz
@@ -211,7 +211,7 @@ class DetectControllerViewV2(View):
                             'app_type': app_type,
                             'push_type': push_type,
                             'token_val': token_val,
-                            'jg_token_val': jg_token_val if push_type in ['5', '6'] and jg_token_val else '',
+                            'jg_token_val': jg_token_val,
                             'm_code': m_code,
                             'addTime': nowTime,
                             'updTime': nowTime,
@@ -220,8 +220,6 @@ class DetectControllerViewV2(View):
                         }
                         # 绑定设备推送
                         UidPushModel.objects.create(**uid_push_create_dict)
-                if appBundleId == 0 or appBundleId == '0':
-                    LOGGER.info('detectV2/changeStatus接口推送数据:{}'.format(request_dict))
                 return response.json(0)
 
             if status == 0:
@@ -237,7 +235,7 @@ class DetectControllerViewV2(View):
                             'app_type': app_type,
                             'push_type': push_type,
                             'token_val': token_val,
-                            'jg_token_val': jg_token_val if push_type in ['5', '6'] and jg_token_val else '',
+                            'jg_token_val': jg_token_val,
                             'updTime': nowTime,
                             'lang': lang,
                             'tz': tz
@@ -251,7 +249,7 @@ class DetectControllerViewV2(View):
                             'app_type': app_type,
                             'push_type': push_type,
                             'token_val': token_val,
-                            'jg_token_val': jg_token_val if push_type in ['5', '6'] and jg_token_val else '',
+                            'jg_token_val': jg_token_val,
                             'm_code': m_code,
                             'addTime': nowTime,
                             'updTime': nowTime,
@@ -260,8 +258,6 @@ class DetectControllerViewV2(View):
                         }
                         # 绑定设备推送
                         UidPushModel.objects.create(**uid_push_create_dict)
-                if appBundleId == 0 or appBundleId == '0':
-                    LOGGER.info('detectV2/changeStatus接口推送数据:{}'.format(request_dict))
                 if interval:
                     self.do_delete_redis(uid, interval)
                 else:

+ 3 - 2
Controller/EquipmentManagerV3.py

@@ -119,6 +119,7 @@ class EquipmentManagerV3(View):
         app_type = request_dict.get('app_type', None)
         push_type = request_dict.get('push_type', None)
         token_val = request_dict.get('token_val', None)
+        jg_token_val = request_dict.get('jg_token_val', '')
         lang = request_dict.get('lang', 'en')
         tz = request_dict.get('tz', '0')
 
@@ -251,6 +252,7 @@ class EquipmentManagerV3(View):
                         'app_type': app_type,
                         'push_type': push_type,
                         'token_val': token_val,
+                        'jg_token_val': jg_token_val,
                         'updTime': nowTime,
                         'lang': lang,
                         'tz': tz
@@ -264,6 +266,7 @@ class EquipmentManagerV3(View):
                         'app_type': app_type,
                         'push_type': push_type,
                         'token_val': token_val,
+                        'jg_token_val': jg_token_val,
                         'm_code': m_code,
                         'addTime': nowTime,
                         'updTime': nowTime,
@@ -272,8 +275,6 @@ class EquipmentManagerV3(View):
                     }
                     # 绑定设备推送
                     UidPushModel.objects.create(**uid_push_create_dict)
-                if appBundleId == 0 or appBundleId == '0':
-                    LOGGER.info('v3/equipment/add接口推送数据:{}'.format(request_dict))
             # 查询uid_channel表有无该uid的数据
             uid_channel_set = UidChannelSetModel.objects.filter(uid_id=UidSet_id)
             if not uid_channel_set.exists():

+ 8 - 5
Controller/UserController.py

@@ -2408,6 +2408,7 @@ class InitInfoView(View):
     def init_info(self, request_dict, userID, response, request):
         # 未读的系统消息
         token_val = request_dict.get('token_val', None)
+        jg_token_val = request_dict.get('jg_token_val', '')
         m_code = request_dict.get('m_code', None)
         push_type = request_dict.get('push_type', None)
         appBundleId = request_dict.get('appBundleId', None)
@@ -2418,7 +2419,8 @@ class InitInfoView(View):
             m_code = m_code[4:]
         if all([token_val, push_type, appBundleId, userID]):
             self.save_push_config(userID, appBundleId, push_type, token_val, m_code, lang, tz)
-            self.save_or_creat_uid_push(userID, appBundleId, push_type, token_val, m_code, lang, tz, now_time)
+            self.save_or_creat_uid_push(userID, appBundleId, push_type, token_val, m_code, lang, tz, now_time,
+                                        jg_token_val)
             if appBundleId:
                 user_ex_qs = UserExModel.objects.filter(userID_id=userID)
                 user_ex = None
@@ -2481,13 +2483,14 @@ class InitInfoView(View):
             print('出错了~异步保存配置信息错误,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
 
     @staticmethod
-    def save_or_creat_uid_push(user_id, app_bundle_id, push_type, token_val, m_code, lang, tz, now_time):
+    def save_or_creat_uid_push(user_id, app_bundle_id, push_type, token_val, m_code, lang, tz, now_time, jg_token_val):
         """
         异步保存推送配置
         @param user_id: 用户id
         @param app_bundle_id: app版本包id
         @param push_type: 推送类型 0:Ios,1:Google,2:国内极光
         @param token_val: 推送token
+        @param jg_token_val: 极光推送token
         @param m_code: 手机唯一标识
         @param lang: 语言
         @param tz: 时区
@@ -2502,12 +2505,12 @@ class InitInfoView(View):
                 for item in uid_set:
                     uid_push_qs = UidPushModel.objects.filter(userID=user_id, m_code=m_code, uid_set_id=item['id'])
                     if uid_push_qs.exists():
-                        if uid_push_qs.first().token_val != token_val:
-                            uid_push_qs.update(token_val=token_val, push_type=push_type)
+                        uid_push_qs.update(token_val=token_val, push_type=push_type, jg_token_val=jg_token_val)
                     else:
                         UidPushModel.objects.create(userID_id=user_id, appBundleId=app_bundle_id, app_type=app_type,
                                                     push_type=push_type, token_val=token_val, m_code=m_code, lang=lang,
-                                                    tz=tz, addTime=now_time, updTime=now_time, uid_set_id=item['id'])
+                                                    tz=tz, addTime=now_time, updTime=now_time, uid_set_id=item['id'],
+                                                    jg_token_val=jg_token_val)
         except Exception as e:
             LOGGER.info('出错了~保存推送配置信息错误,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))