|
@@ -37,7 +37,7 @@ from django.views.generic import View
|
|
|
from jwt.algorithms import RSAAlgorithm
|
|
|
from ratelimit import limits
|
|
|
|
|
|
-from Ansjer.config import AuthCode_Expire, SERVER_DOMAIN, APNS_CONFIG, JPUSH_CONFIG, FCM_CONFIG, TUTK_PUSH_DOMAIN
|
|
|
+from Ansjer.config import AuthCode_Expire, SERVER_DOMAIN, APNS_CONFIG, JPUSH_CONFIG, FCM_CONFIG, TUTK_PUSH_DOMAIN, LOGGER
|
|
|
from Ansjer.config import BASE_DIR, CONFIG_EUR, CONFIG_INFO, SERVER_DOMAIN_EUR, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
|
|
|
from Controller.CheckUserData import DataValid, date_handler, RandomStr
|
|
|
from Model.models import Device_User, Role, UidPushModel, UserOauth2Model, UserExModel, Device_Info, UidSetModel, \
|
|
@@ -2328,16 +2328,7 @@ class InitInfoView(View):
|
|
|
now_time = int(time.time())
|
|
|
if all([token_val, push_type, appBundleId, userID]):
|
|
|
self.save_push_config(userID, appBundleId, push_type, token_val, m_code, lang, tz)
|
|
|
- if m_code:
|
|
|
- # 获取设备推送状态
|
|
|
- update_dict = {
|
|
|
- 'token_val': token_val,
|
|
|
- 'push_type': push_type,
|
|
|
- 'tz': tz,
|
|
|
- }
|
|
|
- # 更新当前用户推送设备状态
|
|
|
- UidPushModel.objects.filter(userID_id=userID, m_code=m_code). \
|
|
|
- update(**update_dict)
|
|
|
+ self.save_or_creat_uid_push(userID, appBundleId, push_type, token_val, m_code, lang, tz)
|
|
|
if appBundleId:
|
|
|
user_ex_qs = UserExModel.objects.filter(userID_id=userID)
|
|
|
user_ex = None
|
|
@@ -2399,6 +2390,37 @@ class InitInfoView(View):
|
|
|
except Exception as e:
|
|
|
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):
|
|
|
+ """
|
|
|
+ 异步保存推送配置
|
|
|
+ @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
|
|
|
+ now_time = int(time.time())
|
|
|
+ device_info = Device_Info.objects.filter(userID=user_id).values('UID')
|
|
|
+ if device_info.exists():
|
|
|
+ uid_set = UidSetModel.objects.filter(uid__in=list(device_info)).values('id')
|
|
|
+ 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)
|
|
|
+ else:
|
|
|
+ UidPushModel.objects.create(userID=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'])
|
|
|
+ except Exception as e:
|
|
|
+ LOGGER.info('出错了~保存推送配置信息错误,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)
|