|
@@ -1274,6 +1274,66 @@ class InitInfoView(View):
|
|
|
# 未读的系统消息
|
|
|
sm_count = SysMsgModel.objects.filter(userID_id=userID, status=0).count()
|
|
|
|
|
|
+ token_val = request_dict.get('token_val', None)
|
|
|
+ m_code = request_dict.get('m_code', None)
|
|
|
+ push_type = request_dict.get('push_type', None)
|
|
|
+ appBundleId = request_dict.get('appBundleId', None)
|
|
|
+ tz = request_dict.get('tz', '0')
|
|
|
+ lang = request_dict.get('lang', '') # 语言区域
|
|
|
+ # region = request_dict.get('region', '') # 语言区域
|
|
|
+ nowTime = int(time.time())
|
|
|
+ if all([token_val, push_type, appBundleId]):
|
|
|
+ push_type = int(push_type)
|
|
|
+ if push_type == 0:
|
|
|
+ if appBundleId not in APNS_CONFIG.keys():
|
|
|
+ return response.json(904)
|
|
|
+ elif push_type == 1:
|
|
|
+ if appBundleId not in FCM_CONFIG.keys():
|
|
|
+ return response.json(904)
|
|
|
+ elif push_type == 2:
|
|
|
+ if appBundleId not in JPUSH_CONFIG.keys():
|
|
|
+ return response.json(904)
|
|
|
+ else:
|
|
|
+ return response.json(173)
|
|
|
+ uid_list = ModelService.get_uid_list(userID=userID)
|
|
|
+ if uid_list:
|
|
|
+ # 获取设备推送状态
|
|
|
+ update_dict = {
|
|
|
+ 'token_val': token_val,
|
|
|
+ 'push_type': push_type,
|
|
|
+ 'tz': tz,
|
|
|
+ }
|
|
|
+ # 更新当前用户推送设备状态
|
|
|
+ UidPushModel.objects.filter(userID_id=userID, m_code=m_code,uid_set__detect_status=1).update(**update_dict)
|
|
|
+ if appBundleId:
|
|
|
+ user_extend_qs = UserExtendModel.objects.filter(userID_id=userID)
|
|
|
+ if user_extend_qs.exists():
|
|
|
+ update_dict = {
|
|
|
+ 'updTime': nowTime,
|
|
|
+ 'appBundleId': appBundleId,
|
|
|
+ 'region': lang
|
|
|
+ # 'is_cn':
|
|
|
+ }
|
|
|
+ user_extend_qs.update(**update_dict)
|
|
|
+ else:
|
|
|
+ create_dict = {
|
|
|
+ 'addTime': nowTime,
|
|
|
+ 'updTime': nowTime,
|
|
|
+ 'appBundleId': appBundleId,
|
|
|
+ 'userID_id': userID,
|
|
|
+ 'region': lang
|
|
|
+ }
|
|
|
+ UserExtendModel.objects.create(**create_dict)
|
|
|
+ res = {
|
|
|
+ 'usmsg': sm_count
|
|
|
+ }
|
|
|
+ return response.json(0, res)
|
|
|
+
|
|
|
+ # 初始化设备token
|
|
|
+ def init_uid22(self, request_dict, userID, response):
|
|
|
+ # 未读的系统消息
|
|
|
+ sm_count = SysMsgModel.objects.filter(userID_id=userID, status=0).count()
|
|
|
+
|
|
|
token_val = request_dict.get('token_val', None)
|
|
|
m_code = request_dict.get('m_code', None)
|
|
|
push_type = request_dict.get('push_type', None)
|
|
@@ -1304,8 +1364,8 @@ class InitInfoView(View):
|
|
|
uid_list = ModelService.get_uid_list(userID=userID)
|
|
|
if uid_list:
|
|
|
# 获取设备推送状态
|
|
|
- uid_set_id_list = UidSetModel.objects.filter(uid__in=uid_list, detect_status=1). \
|
|
|
- values_list('id', flat=True)
|
|
|
+ uid_set_id_list = UidSetModel.objects.filter(uid__in=uid_list, detect_status=1).values_list('id',
|
|
|
+ flat=True)
|
|
|
if uid_set_id_list:
|
|
|
# 批量绑定推送
|
|
|
qs_list = []
|