浏览代码

网关推送表增加极光推送token

peng 11 月之前
父节点
当前提交
d4812f595f
共有 2 个文件被更改,包括 15 次插入7 次删除
  1. 14 7
      Controller/UserController.py
  2. 1 0
      Model/models.py

+ 14 - 7
Controller/UserController.py

@@ -961,7 +961,9 @@ class v2authCodeView(TemplateView):
             start_time = time.time()
             send_res = self.send_email(send_data, email, identifyingCode)  # 发送验证码到用户邮箱
             end_time = time.time()
-            LOGGER.info('{}阿里云邮箱发送验证码执行时间: {:.3f} 秒,email:{}'.format(CONFIG_INFO, (end_time - start_time), email))
+            LOGGER.info(
+                '{}阿里云邮箱发送验证码执行时间: {:.3f} 秒,email:{}'.format(CONFIG_INFO, (end_time - start_time),
+                                                                            email))
             if send_res is not True:
                 return response.json(44)
             # 单个邮箱验证码有效期5分钟
@@ -2566,7 +2568,7 @@ class InitInfoView(View):
         if m_code[:4] == 'iOS_':
             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_push_config(userID, appBundleId, push_type, token_val, m_code, lang, tz, jg_token_val)
             self.save_or_creat_uid_push(userID, appBundleId, push_type, token_val, m_code, lang, tz, now_time,
                                         jg_token_val)
             if appBundleId:
@@ -2624,13 +2626,14 @@ class InitInfoView(View):
             return False
 
     @staticmethod
-    def save_push_config(user_id, app_bundle_id, push_type, token_val, m_code, lang, tz):
+    def save_push_config(user_id, app_bundle_id, push_type, token_val, m_code, lang, tz, 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 token_val: 极光推送token
         @param m_code: 手机唯一标识
         @param lang: 语言
         @param tz: 时区
@@ -2641,10 +2644,12 @@ class InitInfoView(View):
             gateway_push_qs = GatewayPush.objects.filter(user_id=user_id, m_code=m_code)
             if gateway_push_qs.exists():
                 if gateway_push_qs.first().token_val != token_val:
-                    gateway_push_qs.update(token_val=token_val, push_type=push_type, logout=False)
+                    gateway_push_qs.update(token_val=token_val, push_type=push_type, logout=False,
+                                           jg_token_val=jg_token_val)
             else:
                 GatewayPush.objects.create(user_id=user_id, app_bundle_id=app_bundle_id, app_type=app_type,
-                                           push_type=push_type, token_val=token_val, m_code=m_code, lang=lang, tz=tz)
+                                           push_type=push_type, token_val=token_val, m_code=m_code, lang=lang, tz=tz,
+                                           jg_token_val=jg_token_val)
         except Exception as e:
             print('出错了~异步保存配置信息错误,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
 
@@ -2855,7 +2860,8 @@ class wxAuthSignView(TemplateView):
                         # 如果用户为绑定过则创建用户并进行登录返回token
                         userID = CommonService.getUserID(getUser=False)
                         nickname = res_json['nickname'] + '_' + CommonService.RandomStr(4)
-                        return self.do_register(userID, nickname, response, appBundleID, token_val, token_version, unionID)
+                        return self.do_register(userID, nickname, response, appBundleID, token_val, token_version,
+                                                unionID)
                 else:
                     return response.json(414, 'access_token,openid')
             else:
@@ -4638,7 +4644,8 @@ class AppleAuthLogin(View):
                             nickname = claims['email']
                         else:
                             nickname = 'apple_{num}'.format(num=CommonService.RandomStr(6, False))
-                        return self.do_register(userID, nickname, response, app_bundle_id, token_val, token_version, unionID)
+                        return self.do_register(userID, nickname, response, app_bundle_id, token_val, token_version,
+                                                unionID)
 
                 except Exception as e:
                     print(e)

+ 1 - 0
Model/models.py

@@ -2368,6 +2368,7 @@ class GatewayPush(models.Model):
     push_type = models.IntegerField(default=0,
                                     verbose_name=u'推送类型')  # 0: apns, 1: 安卓gcm, 2: 极光, 3:华为, 4:小米, 5:vivo, 6:oppo, 7:魅族
     token_val = models.CharField(default='', max_length=500, verbose_name=u'设备验证令牌')
+    jg_token_val = models.CharField(default='', max_length=500, verbose_name=u'极光推送令牌')
     m_code = models.CharField(default='', max_length=64, db_index=True, verbose_name='手机唯一标识')
     lang = models.CharField(default='en', max_length=8, verbose_name='推送语言')
     tz = models.CharField(default='0', max_length=8, verbose_name='时区')