|
@@ -20,7 +20,7 @@ import oss2
|
|
from django.http import JsonResponse
|
|
from django.http import JsonResponse
|
|
from django.views.generic.base import View
|
|
from django.views.generic.base import View
|
|
from pyfcm import FCMNotification
|
|
from pyfcm import FCMNotification
|
|
-
|
|
|
|
|
|
+from AnsjerPush.config import SERVER_TYPE
|
|
from AnsjerPush.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, DETECT_PUSH_DOMAIN, JPUSH_CONFIG, FCM_CONFIG, \
|
|
from AnsjerPush.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, DETECT_PUSH_DOMAIN, JPUSH_CONFIG, FCM_CONFIG, \
|
|
APNS_CONFIG, BASE_DIR, APNS_MODE
|
|
APNS_CONFIG, BASE_DIR, APNS_MODE
|
|
from Model.models import Equipment_Info, UidPushModel, SysMsgModel
|
|
from Model.models import Equipment_Info, UidPushModel, SysMsgModel
|
|
@@ -131,7 +131,11 @@ class NotificationView(View):
|
|
detect_interval = 60
|
|
detect_interval = 60
|
|
redisObj.set_data(key=dkey, val=1, expire=detect_interval)
|
|
redisObj.set_data(key=dkey, val=1, expire=detect_interval)
|
|
# 改为1秒
|
|
# 改为1秒
|
|
- redisObj.set_data(key=pkey, val=1, expire=1)
|
|
|
|
|
|
+ # 如果不是正式
|
|
|
|
+ if SERVER_TYPE!="Ansjer.formal_settings":
|
|
|
|
+ redisObj.set_data(key=pkey, val=1, expire=1)
|
|
|
|
+ else:
|
|
|
|
+ redisObj.set_data(key=pkey, val=1, expire=60)
|
|
|
|
|
|
# 打印have_ykey
|
|
# 打印have_ykey
|
|
# return JsonResponse(status=200, data={'pkey': 0, 'have_ykey': have_ykey, 'have_pkey': have_pkey, 'have_ykey': have_dkey})
|
|
# return JsonResponse(status=200, data={'pkey': 0, 'have_ykey': have_ykey, 'have_pkey': have_pkey, 'have_ykey': have_dkey})
|
|
@@ -139,8 +143,11 @@ class NotificationView(View):
|
|
# 旧模式并且没有pkey,重新创建一个
|
|
# 旧模式并且没有pkey,重新创建一个
|
|
if not detect_group and not have_pkey:
|
|
if not detect_group and not have_pkey:
|
|
# 设置推送时间为60秒一次
|
|
# 设置推送时间为60秒一次
|
|
- # 改为1秒
|
|
|
|
- redisObj.set_data(key=pkey, val=1, expire=1)
|
|
|
|
|
|
+ # 如果不是正式
|
|
|
|
+ if SERVER_TYPE != "Ansjer.formal_settings":
|
|
|
|
+ redisObj.set_data(key=pkey, val=1, expire=1)
|
|
|
|
+ else:
|
|
|
|
+ redisObj.set_data(key=pkey, val=1, expire=60)
|
|
auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
|
|
bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
|
|
kwag_args = {
|
|
kwag_args = {
|
|
@@ -221,6 +228,8 @@ class NotificationView(View):
|
|
up['do_apns_code'] = do_apns_code
|
|
up['do_apns_code'] = do_apns_code
|
|
up['do_fcm_code'] = do_fcm_code
|
|
up['do_fcm_code'] = do_fcm_code
|
|
up['do_jpush_code'] = do_jpush_code
|
|
up['do_jpush_code'] = do_jpush_code
|
|
|
|
+ up['test_or_www'] = SERVER_TYPE
|
|
|
|
+
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success 0 or 2','re_list':redis_list})
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success 0 or 2','re_list':redis_list})
|
|
|
|
|
|
elif is_st == '1':
|
|
elif is_st == '1':
|
|
@@ -233,6 +242,7 @@ class NotificationView(View):
|
|
up['do_apns_code'] = do_apns_code
|
|
up['do_apns_code'] = do_apns_code
|
|
up['do_fcm_code'] = do_fcm_code
|
|
up['do_fcm_code'] = do_fcm_code
|
|
up['do_jpush_code'] = do_jpush_code
|
|
up['do_jpush_code'] = do_jpush_code
|
|
|
|
+ up['test_or_www'] = SERVER_TYPE
|
|
res_data = {'code': 0, 'img_push': url, 'msg': 'success 1','re_list':redis_list}
|
|
res_data = {'code': 0, 'img_push': url, 'msg': 'success 1','re_list':redis_list}
|
|
return JsonResponse(status=200, data=res_data)
|
|
return JsonResponse(status=200, data=res_data)
|
|
|
|
|
|
@@ -251,6 +261,7 @@ class NotificationView(View):
|
|
up['do_apns_code'] = do_apns_code
|
|
up['do_apns_code'] = do_apns_code
|
|
up['do_fcm_code'] = do_fcm_code
|
|
up['do_fcm_code'] = do_fcm_code
|
|
up['do_jpush_code'] = do_jpush_code
|
|
up['do_jpush_code'] = do_jpush_code
|
|
|
|
+ up['test_or_www'] = SERVER_TYPE
|
|
|
|
|
|
res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success 3','re_list':redis_list}
|
|
res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success 3','re_list':redis_list}
|
|
return JsonResponse(status=200, data=res_data)
|
|
return JsonResponse(status=200, data=res_data)
|