|
@@ -115,29 +115,31 @@ class DetectControllerViewV2(View):
|
|
|
# 判断推送类型对应key是否存在
|
|
|
print('push_type:', 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)
|
|
|
- dvqs = Device_Info.objects.filter(userID_id=userID, UID=uid)
|
|
|
- # 获取用户区域
|
|
|
- # ip = self.ip
|
|
|
- # ipInfo = CommonService.getIpIpInfo(ip=ip, lang='EN')
|
|
|
- # area = ipInfo['country_name']
|
|
|
- # if area == 'China':
|
|
|
- # DETECT_PUSH_DOMAIN_V2 = 'cn.push.dvema.com'
|
|
|
- # else:
|
|
|
- # DETECT_PUSH_DOMAIN_V2 = 'en.push.dvema.com'
|
|
|
-
|
|
|
- nowTime = int(time.time())
|
|
|
- if dvqs.exists():
|
|
|
+ try:
|
|
|
+ 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)
|
|
|
+ dvqs = Device_Info.objects.filter(userID_id=userID, UID=uid)
|
|
|
+ # 获取用户区域
|
|
|
+ # ip = self.ip
|
|
|
+ # ipInfo = CommonService.getIpIpInfo(ip=ip, lang='EN')
|
|
|
+ # area = ipInfo['country_name']
|
|
|
+ # if area == 'China':
|
|
|
+ # DETECT_PUSH_DOMAIN_V2 = 'cn.push.dvema.com'
|
|
|
+ # else:
|
|
|
+ # DETECT_PUSH_DOMAIN_V2 = 'en.push.dvema.com'
|
|
|
+
|
|
|
+ nowTime = int(time.time())
|
|
|
+ if not dvqs.exists():
|
|
|
+ return response.json(14)
|
|
|
# 修改状态
|
|
|
if status:
|
|
|
dvqs.update(NotificationMode=int(status))
|
|
@@ -194,11 +196,11 @@ class DetectControllerViewV2(View):
|
|
|
UidPushModel.objects.create(**uid_push_create_dict)
|
|
|
return response.json(0)
|
|
|
|
|
|
- if status == 0:
|
|
|
+ if status == '0':
|
|
|
# 状态为0的时候删除redis缓存数据
|
|
|
self.do_delete_redis(uid)
|
|
|
return response.json(0)
|
|
|
- elif status == 1:
|
|
|
+ elif status == '1':
|
|
|
uid_push_qs = UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=uid)
|
|
|
|
|
|
if uid_push_qs.exists():
|
|
@@ -251,8 +253,9 @@ class DetectControllerViewV2(View):
|
|
|
detectUrls = "{DETECT_PUSH_DOMAIN_V2}notifyV2/push?etk={etk}&company_secrete={company_secrete}®ion={region}". \
|
|
|
format(etk=etk, company_secrete=company_secrete, DETECT_PUSH_DOMAIN_V2=urls, region=region)
|
|
|
return response.json(0, {'detectUrl': detectUrl, 'detectUrls': detectUrls})
|
|
|
- else:
|
|
|
- return response.json(14)
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ return response.json(500, repr(e))
|
|
|
|
|
|
def do_delete_redis(self, uid, detect_interval=0):
|
|
|
keyPattern = '{uid}*'.format(uid=uid)
|