|
@@ -6,7 +6,7 @@ import oss2
|
|
|
from django.http import JsonResponse
|
|
|
from django.views.generic.base import View
|
|
|
|
|
|
-from AnsjerPush.config import CONFIG_INFO, CONFIG_CN
|
|
|
+from AnsjerPush.config import CONFIG_INFO, CONFIG_CN, CONFIG_US, CONFIG_EUR
|
|
|
from AnsjerPush.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Service.DevicePushService import DevicePushService
|
|
@@ -52,6 +52,7 @@ class NotificationView(View):
|
|
|
|
|
|
V1_PUSH_LOGGER.info('旧移动侦测接口uid:{},时间戳:{},事件类型:{}'.format(uid, n_time, event_type))
|
|
|
|
|
|
+ is_st = int(is_st)
|
|
|
event_type = int(event_type)
|
|
|
pkey = '{}_{}_{}_ptl'.format(uid, event_type, channel)
|
|
|
ykey = '{}_redis_qs'.format(uid)
|
|
@@ -134,24 +135,29 @@ class NotificationView(View):
|
|
|
kwargs=params)
|
|
|
push_thread.start()
|
|
|
|
|
|
- res_data = {}
|
|
|
- if is_st == '0' or is_st == '2':
|
|
|
- res_data = {'code': 0, 'msg': 'success 0 or 2'}
|
|
|
- return JsonResponse(status=200, data=res_data)
|
|
|
-
|
|
|
- elif is_st == '1':
|
|
|
- obj = '{}/{}/{}.jpeg'.format(uid, channel, n_time)
|
|
|
- url = bucket.sign_url('PUT', obj, 3600)
|
|
|
- res_data = {'code': 0, 'img_push': url, 'msg': 'success 1'}
|
|
|
-
|
|
|
- elif is_st == '3':
|
|
|
- img_url_list = []
|
|
|
- for i in range(int(is_st)):
|
|
|
- obj = '{}/{}/{}_{}.jpeg'.format(uid, channel, n_time, i)
|
|
|
- url = bucket.sign_url('PUT', obj, 3600)
|
|
|
- img_url_list.append(url)
|
|
|
-
|
|
|
- res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success 3'}
|
|
|
+ # 对象存储区域
|
|
|
+ # region: 国外(1), 国内(2)
|
|
|
+ # 测试/国内: 阿里云(1), 美洲: oci凤凰城(3), 欧洲: oci伦敦(4)
|
|
|
+ region = 1
|
|
|
+ if CONFIG_INFO == CONFIG_US:
|
|
|
+ storage_location = 3
|
|
|
+ elif CONFIG_INFO == CONFIG_EUR:
|
|
|
+ storage_location = 4
|
|
|
+ else:
|
|
|
+ region = 2
|
|
|
+ storage_location = 1
|
|
|
+ # 获取图片上传链接
|
|
|
+ kwargs = {
|
|
|
+ 'is_st': is_st,
|
|
|
+ 'uid': uid,
|
|
|
+ 'channel': channel,
|
|
|
+ 'n_time': n_time,
|
|
|
+ 'region': region,
|
|
|
+ 'aws_s3_client': '',
|
|
|
+ 'storage_location': storage_location,
|
|
|
+ 'oss_bucket': bucket
|
|
|
+ }
|
|
|
+ res_data = DevicePushService.get_res_data(**kwargs)
|
|
|
|
|
|
V1_PUSH_LOGGER.info('旧推送接口响应,uid:{},n_time:{},事件类型:{},响应:{}'.
|
|
|
format(uid, n_time, event_type, json.dumps(res_data)))
|