|
@@ -1,33 +1,15 @@
|
|
|
-#!/usr/bin/env python3
|
|
|
-# -*- coding: utf-8 -*-
|
|
|
-"""
|
|
|
-@Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
|
|
|
-@AUTHOR: ASJRD018
|
|
|
-@NAME: AnsjerFormal
|
|
|
-@software: PyCharm
|
|
|
-@DATE: 2019/1/14 15:57
|
|
|
-@Version: python3.6
|
|
|
-@MODIFY DECORD:ansjer dev
|
|
|
-@file: DetectController.py
|
|
|
-@Contact: chanjunkai@163.com
|
|
|
-"""
|
|
|
import json
|
|
|
-import os
|
|
|
import time
|
|
|
|
|
|
-import apns2
|
|
|
import boto3
|
|
|
import botocore
|
|
|
-import jpush as jpush
|
|
|
import oss2
|
|
|
from botocore import client
|
|
|
from django.http import JsonResponse
|
|
|
from django.views.generic.base import View
|
|
|
-from pyfcm import FCMNotification
|
|
|
|
|
|
from Ansjer.config import DETECT_PUSH_DOMAIN, DETECT_PUSH_DOMAINS, DETECT_PUSH_DOMAIN_JIUAN, DETECT_PUSH_DOMAINS_JIUAN, \
|
|
|
- OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, \
|
|
|
- JPUSH_CONFIG, FCM_CONFIG, APNS_CONFIG, BASE_DIR, APNS_MODE, SERVER_TYPE
|
|
|
+ OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
|
|
|
from Ansjer.config import PUSH_REDIS_ADDRESS
|
|
|
from Model.models import Device_Info, VodHlsModel, Equipment_Info, UidSetModel, UidPushModel, CompanyModel, SysMsgModel, \
|
|
|
AiService
|
|
@@ -35,7 +17,6 @@ from Object.ETkObject import ETkObject
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
|
-from Object.UidTokenObject import UidTokenObject
|
|
|
from Service.CommonService import CommonService
|
|
|
from Service.EquipmentInfoService import EquipmentInfoService
|
|
|
|
|
@@ -68,7 +49,6 @@ class DetectControllerViewV2(View):
|
|
|
userID = tko.userID
|
|
|
# 修改推送设置
|
|
|
if operation == 'changeStatus':
|
|
|
- print("进入changeStatus")
|
|
|
return self.do_change_status(userID, request_dict, response)
|
|
|
# 查询推送信息
|
|
|
elif operation == 'queryInfo':
|
|
@@ -89,11 +69,10 @@ class DetectControllerViewV2(View):
|
|
|
status = request_dict.get('status', None)
|
|
|
m_code = request_dict.get('m_code', None)
|
|
|
uid = request_dict.get('uid', None)
|
|
|
- # 设备语言
|
|
|
lang = request_dict.get('lang', 'en')
|
|
|
tz = request_dict.get('tz', '0')
|
|
|
company_secrete = request_dict.get('company_secrete', None)
|
|
|
- region = request_dict.get('region', None) # app必须传:2:国内 1:国外
|
|
|
+ region = request_dict.get('region', None) # app必须传:1:国外,2:国内
|
|
|
electricity_status = request_dict.get('electricity_status', None)
|
|
|
if not region:
|
|
|
return response.json(444, 'region')
|
|
@@ -117,22 +96,8 @@ class DetectControllerViewV2(View):
|
|
|
# 关闭推送
|
|
|
if not all([appBundleId, app_type, token_val, uid, m_code]):
|
|
|
return response.json(444, 'appBundleId,app_type,token_val,uid,m_code')
|
|
|
- # 判断推送类型对应key是否存在
|
|
|
- print('push_type:', push_type)
|
|
|
|
|
|
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)
|
|
|
-
|
|
|
# 判断用户是否拥有设备
|
|
|
device_info_qs = Device_Info.objects.filter(userID_id=userID, UID=uid)
|
|
|
if not device_info_qs.exists():
|
|
@@ -227,7 +192,6 @@ class DetectControllerViewV2(View):
|
|
|
}
|
|
|
uid_push_qs.update(**uid_push_update_dict)
|
|
|
else:
|
|
|
- # uid_set_id = uid_set_qs[0].id
|
|
|
uid_push_create_dict = {
|
|
|
'uid_set_id': uid_set_id,
|
|
|
'userID_id': userID,
|
|
@@ -248,9 +212,6 @@ class DetectControllerViewV2(View):
|
|
|
self.do_delete_redis(uid, interval)
|
|
|
else:
|
|
|
self.do_delete_redis(uid)
|
|
|
- # utko = UidTokenObject()
|
|
|
- # # right
|
|
|
- # utko.generate(data={'uid': uid})
|
|
|
etkObj = ETkObject(etk='')
|
|
|
etk = etkObj.encrypt(uid)
|
|
|
|
|
@@ -440,8 +401,6 @@ class DetectControllerViewV2(View):
|
|
|
print(repr(e))
|
|
|
return response.json(474)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
def do_update_interval(self, userID, request_dict, response):
|
|
|
uid = request_dict.get('uid', None)
|
|
|
interval = request_dict.get('interval', None)
|