|
@@ -32,6 +32,7 @@ from Service.CommonService import CommonService
|
|
|
|
|
|
|
|
|
# http://test.dvema.com/notify/push?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJQMldOR0pSRDJFSEE1RVU5MTExQSJ9.xOCI5lerk8JOs5OcAzunrKCfCrtuPIZ3AnkMmnd-bPY&n_time=1526845794&channel=1&event_type=51&is_st=0
|
|
|
+# http://test.dvema.com/notify/push?etk=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJQMldOR0pSRDJFSEE1RVU5MTExQSJ9.xOCI5lerk8JOs5OcAzunrKCfCrtuPIZ3AnkMmnd-bPY&n_time=1526845794&channel=1&event_type=51&is_st=0
|
|
|
|
|
|
|
|
|
# 移动侦测接口
|
|
@@ -47,14 +48,15 @@ class NotificationView(View):
|
|
|
# # operation = kwargs.get('operation')
|
|
|
# return self.validation(request.POST)
|
|
|
|
|
|
- def validation11(self, request_dict):
|
|
|
+ def validation(self, request_dict):
|
|
|
response = ResponseObject()
|
|
|
uidToken = request_dict.get('uidToken', None)
|
|
|
+ etk = request_dict.get('etk', None)
|
|
|
channel = request_dict.get('channel', '1')
|
|
|
n_time = request_dict.get('n_time', None)
|
|
|
event_type = request_dict.get('event_type', None)
|
|
|
is_st = request_dict.get('is_st', None)
|
|
|
- if not all([uidToken, channel, n_time]):
|
|
|
+ if not all([channel, n_time]):
|
|
|
return JsonResponse(status=200, data={
|
|
|
'code': 444,
|
|
|
'msg': 'param is wrong'})
|
|
@@ -218,7 +220,7 @@ class NotificationView(View):
|
|
|
else:
|
|
|
return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
|
|
|
|
|
|
-######
|
|
|
+
|
|
|
def do_jpush(self, request_dict, uaql, response, uid, channel, nickname):
|
|
|
event_type = request_dict.get('event_type', None)
|
|
|
n_time = request_dict.get('n_time', None)
|
|
@@ -410,39 +412,34 @@ class PushNotificationView(View):
|
|
|
return JsonResponse(status=200, data=res_data)
|
|
|
else:
|
|
|
redisObj.set_data(key=pkey, val=1, expire=60)
|
|
|
- uid_set_qs = UidSetModel.objects.filter(uid=uid, detect_status=1)
|
|
|
- if uid_set_qs.exists():
|
|
|
- uid_set_id = uid_set_qs[0].id
|
|
|
- uid_push_qs = UidPushModel.objects.filter(uid_set__id=uid_set_id). \
|
|
|
- values('token_val', 'app_type', 'appBundleId', 'push_type',
|
|
|
- 'userID_id', 'userID__NickName', 'lang', 'tz')
|
|
|
- if uid_set_qs.exists():
|
|
|
- auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
- bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
|
|
|
- self.do_bulk_create_info(uid_push_qs, n_time, channel, event_type, is_st, uid)
|
|
|
- if is_st == '0' or is_st == '2':
|
|
|
- return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
|
|
|
- elif is_st == '1':
|
|
|
- # Endpoint以杭州为例,其它Region请按实际情况填写。
|
|
|
- obj = '{uid}/{channel}/{filename}.jpeg'.format(uid=uid, channel=channel, filename=n_time)
|
|
|
+ uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid,uid_set__detect_status=1). \
|
|
|
+ values('token_val', 'app_type', 'appBundleId', 'push_type',
|
|
|
+ 'userID_id', 'userID__NickName', 'lang', 'tz','uid_set__nickname')
|
|
|
+ if uid_push_qs.exists():
|
|
|
+ auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
|
+ bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'apg')
|
|
|
+ self.do_bulk_create_info(uid_push_qs, n_time, channel, event_type, is_st, uid)
|
|
|
+ if is_st == '0' or is_st == '2':
|
|
|
+ return JsonResponse(status=200, data={'code': 0, 'msg': 'success'})
|
|
|
+ elif is_st == '1':
|
|
|
+ # Endpoint以杭州为例,其它Region请按实际情况填写。
|
|
|
+ obj = '{uid}/{channel}/{filename}.jpeg'.format(uid=uid, channel=channel, filename=n_time)
|
|
|
+ # 设置此签名URL在60秒内有效。
|
|
|
+ url = bucket.sign_url('PUT', obj, 7200)
|
|
|
+ res_data = {'code': 0, 'img_push': url, 'msg': 'success'}
|
|
|
+ return JsonResponse(status=200, data=res_data)
|
|
|
+ elif is_st == '3':
|
|
|
+ # 人形检测带动图
|
|
|
+ img_url_list = []
|
|
|
+ for i in range(int(is_st)):
|
|
|
+ obj = '{uid}/{channel}/{filename}_{st}.jpeg'. \
|
|
|
+ format(uid=uid, channel=channel, filename=n_time, st=i)
|
|
|
# 设置此签名URL在60秒内有效。
|
|
|
url = bucket.sign_url('PUT', obj, 7200)
|
|
|
- res_data = {'code': 0, 'img_push': url, 'msg': 'success'}
|
|
|
- return JsonResponse(status=200, data=res_data)
|
|
|
- elif is_st == '3':
|
|
|
- # 人形检测带动图
|
|
|
- img_url_list = []
|
|
|
- for i in range(int(is_st)):
|
|
|
- obj = '{uid}/{channel}/{filename}_{st}.jpeg'. \
|
|
|
- format(uid=uid, channel=channel, filename=n_time, st=i)
|
|
|
- # 设置此签名URL在60秒内有效。
|
|
|
- url = bucket.sign_url('PUT', obj, 7200)
|
|
|
- img_url_list.append(url)
|
|
|
- res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success'}
|
|
|
- return JsonResponse(status=200, data=res_data)
|
|
|
+ img_url_list.append(url)
|
|
|
+ res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success'}
|
|
|
+ return JsonResponse(status=200, data=res_data)
|
|
|
|
|
|
- else:
|
|
|
- return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
|
|
|
else:
|
|
|
return JsonResponse(status=200, data={'code': 404, 'msg': 'data is not exist'})
|
|
|
else:
|
|
@@ -457,12 +454,15 @@ class PushNotificationView(View):
|
|
|
for dv in uaqs:
|
|
|
userID_id = dv["userID_id"]
|
|
|
if userID_id not in userID_ids:
|
|
|
+ uid_nickname = dv['uid_set__nickname']
|
|
|
+ if not uid_nickname:
|
|
|
+ uid_nickname = uid
|
|
|
add_data = {
|
|
|
'userID_id': dv["userID_id"],
|
|
|
'eventTime': n_time,
|
|
|
'eventType': event_type,
|
|
|
'devUid': uid,
|
|
|
- 'devNickName': uid,
|
|
|
+ 'devNickName': uid_nickname,
|
|
|
'Channel': channel,
|
|
|
'alarm': 'Motion \tChannel:{channel}'.format(channel=channel),
|
|
|
'is_st': int(is_st),
|