|
@@ -15,6 +15,7 @@ import base64
|
|
|
import datetime
|
|
|
import logging
|
|
|
import random
|
|
|
+import threading
|
|
|
import time
|
|
|
import traceback
|
|
|
from io import BytesIO
|
|
@@ -2208,13 +2209,9 @@ class InitInfoView(View):
|
|
|
return response.json(904)
|
|
|
else:
|
|
|
return response.json(444, 'push_type')
|
|
|
- app_type = 1 if push_type == 0 else 2
|
|
|
- gateway_push_qs = GatewayPush.objects.filter(user_id=userID, m_code=m_code)
|
|
|
- if gateway_push_qs.exists():
|
|
|
- gateway_push_qs.update(token_val=token_val, logout=False)
|
|
|
- else:
|
|
|
- GatewayPush.objects.create(user_id=userID, app_bundle_id=appBundleId, app_type=app_type,
|
|
|
- push_type=push_type, token_val=token_val, m_code=m_code, lang=lang, tz=tz)
|
|
|
+ asy = threading.Thread(target=self.save_push_config,
|
|
|
+ args=(userID, appBundleId, push_type, token_val, m_code, lang, tz))
|
|
|
+ asy.start()
|
|
|
if m_code:
|
|
|
# 获取设备推送状态
|
|
|
update_dict = {
|
|
@@ -2258,6 +2255,31 @@ class InitInfoView(View):
|
|
|
res = {'usmsg': 0} # 预留字段, 有版本app该字段去掉会报错
|
|
|
return response.json(0, res)
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def save_push_config(user_id, app_bundle_id, push_type, token_val, m_code, lang, tz):
|
|
|
+ """
|
|
|
+ 异步保存新推送配置
|
|
|
+ @param user_id: 用户id
|
|
|
+ @param app_bundle_id: app版本包id
|
|
|
+ @param push_type: 推送类型 0:Ios,1:Google,2:国内极光
|
|
|
+ @param token_val: 推送token
|
|
|
+ @param m_code: 手机唯一标识
|
|
|
+ @param lang: 语言
|
|
|
+ @param tz: 时区
|
|
|
+ @return: None
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ app_type = 1 if push_type == 0 else 2
|
|
|
+ gateway_push_qs = GatewayPush.objects.filter(user_id=user_id, m_code=m_code)
|
|
|
+ if gateway_push_qs.exists():
|
|
|
+ gateway_push_qs.update(token_val=token_val, logout=False)
|
|
|
+ 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)
|
|
|
+ except Exception as e:
|
|
|
+ print('出错了~异步保存配置信息错误,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+
|
|
|
+
|
|
|
def update_country(self, request_dict, response, request):
|
|
|
username = request_dict.get('unique', None)
|
|
|
appBundleId = request_dict.get('appBundleId', None)
|