|
@@ -23,7 +23,8 @@ from AnsjerPush.Config.aiConfig import DEVICE_EVENT_TYPE, ALGORITHM_COMBO_TYPES
|
|
from AnsjerPush.MessageConfig import EVENT_CONFIGS, DEFAULT_TEXTS, CHANNEL_MAP, MSG_CONFIG
|
|
from AnsjerPush.MessageConfig import EVENT_CONFIGS, DEFAULT_TEXTS, CHANNEL_MAP, MSG_CONFIG
|
|
from AnsjerPush.config import CONFIG_INFO, CONFIG_CN, MULTI_CHANNEL_TYPE_LIST, SYS_EVENT_TYPE_LIST, AWS_ACCESS_KEY_ID, \
|
|
from AnsjerPush.config import CONFIG_INFO, CONFIG_CN, MULTI_CHANNEL_TYPE_LIST, SYS_EVENT_TYPE_LIST, AWS_ACCESS_KEY_ID, \
|
|
AWS_SECRET_ACCESS_KEY, EVENT_DICT, EVENT_DICT_CN, CONFIG_TEST, HUAWEICLOUD_AK, HUAWEICLOUD_SK, \
|
|
AWS_SECRET_ACCESS_KEY, EVENT_DICT, EVENT_DICT_CN, CONFIG_TEST, HUAWEICLOUD_AK, HUAWEICLOUD_SK, \
|
|
- HUAWEICLOUD_OBS_SERVER, HUAWEICLOUD_PUSH_BUKET, OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, JPUSH_UID_LIST
|
|
|
|
|
|
+ HUAWEICLOUD_OBS_SERVER, HUAWEICLOUD_PUSH_BUKET, OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, JPUSH_UID_LIST, \
|
|
|
|
+ DATA_PUSH_EVENT_TYPE_LIST, PRIMARY_USERS_PUSH_EVENT_TYPE_LIST
|
|
from AnsjerPush.config import XMPUSH_CONFIG, OPPOPUSH_CONFIG, XM_PUSH_CHANNEL_ID, XM_PUSH_CHANNEL_DICT
|
|
from AnsjerPush.config import XMPUSH_CONFIG, OPPOPUSH_CONFIG, XM_PUSH_CHANNEL_ID, XM_PUSH_CHANNEL_DICT
|
|
from Model.models import UidPushModel, SysMsgModel, DeviceSharePermission, DeviceChannelUserSet, \
|
|
from Model.models import UidPushModel, SysMsgModel, DeviceSharePermission, DeviceChannelUserSet, \
|
|
DeviceChannelUserPermission, UidSetModel, Device_Info, UserAudioVideoPush, PushLog
|
|
DeviceChannelUserPermission, UidSetModel, Device_Info, UserAudioVideoPush, PushLog
|
|
@@ -108,7 +109,7 @@ class DevicePushService:
|
|
@param button: 按钮
|
|
@param button: 按钮
|
|
@return: uid_push_qs
|
|
@return: uid_push_qs
|
|
"""
|
|
"""
|
|
- if event_type not in EventTypeEnumObj.PRIMARY_USERS_PUSH_EVENT_TYPE_LIST.value:
|
|
|
|
|
|
+ if event_type not in PRIMARY_USERS_PUSH_EVENT_TYPE_LIST:
|
|
uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, uid_set__detect_status=1) \
|
|
uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, uid_set__detect_status=1) \
|
|
.exclude(token_val='0'). \
|
|
.exclude(token_val='0'). \
|
|
values('token_val', 'app_type', 'appBundleId', 'm_code', 'push_type', 'userID_id', 'userID__NickName',
|
|
values('token_val', 'app_type', 'appBundleId', 'm_code', 'push_type', 'userID_id', 'userID__NickName',
|
|
@@ -188,7 +189,7 @@ class DevicePushService:
|
|
try:
|
|
try:
|
|
uid = params['uid']
|
|
uid = params['uid']
|
|
params['event_tag'] = cls.get_event_tag(params['ai_type'], params['event_type'], params['detection'])
|
|
params['event_tag'] = cls.get_event_tag(params['ai_type'], params['event_type'], params['detection'])
|
|
- is_app_push = True if params['event_type'] in EventTypeEnumObj.PRIMARY_USERS_PUSH_EVENT_TYPE_LIST.value \
|
|
|
|
|
|
+ is_app_push = True if params['event_type'] in PRIMARY_USERS_PUSH_EVENT_TYPE_LIST \
|
|
else cls.is_send_app_push(
|
|
else cls.is_send_app_push(
|
|
params['event_type'], params['event_tag'], params['app_push_config'], params['app_push'],
|
|
params['event_type'], params['event_tag'], params['app_push_config'], params['app_push'],
|
|
uid, params['channel'])
|
|
uid, params['channel'])
|
|
@@ -212,7 +213,7 @@ class DevicePushService:
|
|
tz = up['tz']
|
|
tz = up['tz']
|
|
if tz is None or tz == '':
|
|
if tz is None or tz == '':
|
|
tz = 0
|
|
tz = 0
|
|
- if params['event_type'] in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value and push_type in [5, 6]:
|
|
|
|
|
|
+ if params['event_type'] in DATA_PUSH_EVENT_TYPE_LIST and push_type in [5, 6]:
|
|
process_token = up['jg_token_val']
|
|
process_token = up['jg_token_val']
|
|
push_kwargs['jg_token_val'] = up['jg_token_val']
|
|
push_kwargs['jg_token_val'] = up['jg_token_val']
|
|
else:
|
|
else:
|
|
@@ -329,7 +330,7 @@ class DevicePushService:
|
|
|
|
|
|
# 一键通话和视频通话需要实时写入数据
|
|
# 一键通话和视频通话需要实时写入数据
|
|
# 正式服通过定时任务批量写入数据
|
|
# 正式服通过定时任务批量写入数据
|
|
- if params['event_type'] in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value or \
|
|
|
|
|
|
+ if params['event_type'] in DATA_PUSH_EVENT_TYPE_LIST or \
|
|
CONFIG_INFO == CONFIG_TEST:
|
|
CONFIG_INFO == CONFIG_TEST:
|
|
end = 0
|
|
end = 0
|
|
# 缓存数据多于100条,批量保存前100条,否则保存全部
|
|
# 缓存数据多于100条,批量保存前100条,否则保存全部
|
|
@@ -478,7 +479,7 @@ class DevicePushService:
|
|
vsees_huawei_push_object = VseesHuaweiPushObject()
|
|
vsees_huawei_push_object = VseesHuaweiPushObject()
|
|
vsees_huawei_push_object.send_push_notify_message(**push_kwargs)
|
|
vsees_huawei_push_object.send_push_notify_message(**push_kwargs)
|
|
elif push_type == 4: # android xmpush
|
|
elif push_type == 4: # android xmpush
|
|
- if kwargs['event_type'] in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
|
|
|
|
|
|
+ if kwargs['event_type'] in DATA_PUSH_EVENT_TYPE_LIST:
|
|
push_channel = 'push_to_talk'
|
|
push_channel = 'push_to_talk'
|
|
else:
|
|
else:
|
|
push_channel = 'device_reminder'
|
|
push_channel = 'device_reminder'
|
|
@@ -494,7 +495,7 @@ class DevicePushService:
|
|
elif push_type == 8: # android honorpush
|
|
elif push_type == 8: # android honorpush
|
|
push_result = PushObject.android_honorpush(**push_kwargs)
|
|
push_result = PushObject.android_honorpush(**push_kwargs)
|
|
|
|
|
|
- if kwargs['event_type'] in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
|
|
|
|
|
|
+ if kwargs['event_type'] in DATA_PUSH_EVENT_TYPE_LIST:
|
|
close_old_connections()
|
|
close_old_connections()
|
|
# 写入日志表
|
|
# 写入日志表
|
|
PushLog.objects.create(uid=uid, event_type=kwargs['event_type'], created_time=int(time.time()),
|
|
PushLog.objects.create(uid=uid, event_type=kwargs['event_type'], created_time=int(time.time()),
|
|
@@ -614,9 +615,9 @@ class DevicePushService:
|
|
if is_save_msg:
|
|
if is_save_msg:
|
|
msg_type = 'SD卡异常,请重新插拔或格式化SD卡。如问题仍未解决,请联系在线客服。'
|
|
msg_type = 'SD卡异常,请重新插拔或格式化SD卡。如问题仍未解决,请联系在线客服。'
|
|
|
|
|
|
- elif event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
|
|
|
|
|
|
+ elif event_type in DATA_PUSH_EVENT_TYPE_LIST:
|
|
msg_type = '有人呼叫,请点击查看'
|
|
msg_type = '有人呼叫,请点击查看'
|
|
- if event_type not in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value and ai_type > 0 and event_list:
|
|
|
|
|
|
+ if event_type not in DATA_PUSH_EVENT_TYPE_LIST and ai_type > 0 and event_list:
|
|
msg_type = ''.join([DevicePushService.get_event_type_text(lang, item, dealings_type)
|
|
msg_type = ''.join([DevicePushService.get_event_type_text(lang, item, dealings_type)
|
|
for item in event_list])
|
|
for item in event_list])
|
|
if is_sys:
|
|
if is_sys:
|
|
@@ -678,9 +679,9 @@ class DevicePushService:
|
|
msg_type = 'SD card is abnormal, please re-insert or format the SD card. ' \
|
|
msg_type = 'SD card is abnormal, please re-insert or format the SD card. ' \
|
|
'If the problem is still not solved, please contact online customer service.'
|
|
'If the problem is still not solved, please contact online customer service.'
|
|
|
|
|
|
- elif event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
|
|
|
|
|
|
+ elif event_type in DATA_PUSH_EVENT_TYPE_LIST:
|
|
msg_type = 'Someone is calling, please click to view'
|
|
msg_type = 'Someone is calling, please click to view'
|
|
- elif event_type not in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value and ai_type > 0 and event_list:
|
|
|
|
|
|
+ elif event_type not in DATA_PUSH_EVENT_TYPE_LIST and ai_type > 0 and event_list:
|
|
msg_type = ''.join([DevicePushService.get_event_type_text(lang, item, dealings_type)
|
|
msg_type = ''.join([DevicePushService.get_event_type_text(lang, item, dealings_type)
|
|
for item in event_list])
|
|
for item in event_list])
|
|
if is_sys:
|
|
if is_sys:
|
|
@@ -739,11 +740,11 @@ class DevicePushService:
|
|
else:
|
|
else:
|
|
msg_type = MSG_CONFIG[706]['default'].get(lang, '')
|
|
msg_type = MSG_CONFIG[706]['default'].get(lang, '')
|
|
|
|
|
|
- elif event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
|
|
|
|
|
|
+ elif event_type in DATA_PUSH_EVENT_TYPE_LIST:
|
|
msg_type = MSG_CONFIG['data_push'].get(lang, '')
|
|
msg_type = MSG_CONFIG['data_push'].get(lang, '')
|
|
|
|
|
|
# 组合事件处理文案
|
|
# 组合事件处理文案
|
|
- if event_type not in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value and ai_type > 0 and event_list:
|
|
|
|
|
|
+ if event_type not in DATA_PUSH_EVENT_TYPE_LIST and ai_type > 0 and event_list:
|
|
msg_type = ''.join(
|
|
msg_type = ''.join(
|
|
[DevicePushService.get_event_type_text_v2(lang, item, dealings_type) for item in event_list])
|
|
[DevicePushService.get_event_type_text_v2(lang, item, dealings_type) for item in event_list])
|
|
|
|
|
|
@@ -810,7 +811,7 @@ class DevicePushService:
|
|
'extra.channel': channel,
|
|
'extra.channel': channel,
|
|
'extra.jump_type': jump_type
|
|
'extra.jump_type': jump_type
|
|
}
|
|
}
|
|
- if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
|
|
|
|
|
|
+ if event_type in DATA_PUSH_EVENT_TYPE_LIST:
|
|
data['extra.sound_uri'] = 'android.resource://com.ansjer.zccloud_ab/raw/phone_call'
|
|
data['extra.sound_uri'] = 'android.resource://com.ansjer.zccloud_ab/raw/phone_call'
|
|
headers = {
|
|
headers = {
|
|
'Authorization': 'key={}'.format(app_secret)
|
|
'Authorization': 'key={}'.format(app_secret)
|
|
@@ -835,7 +836,7 @@ class DevicePushService:
|
|
android 国内oppo APP消息提醒推送
|
|
android 国内oppo APP消息提醒推送
|
|
"""
|
|
"""
|
|
try:
|
|
try:
|
|
- if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
|
|
|
|
|
|
+ if event_type in DATA_PUSH_EVENT_TYPE_LIST:
|
|
channel_id = XM_PUSH_CHANNEL_ID['push_to_talk']
|
|
channel_id = XM_PUSH_CHANNEL_ID['push_to_talk']
|
|
app_key = OPPOPUSH_CONFIG[appBundleId]['Key']
|
|
app_key = OPPOPUSH_CONFIG[appBundleId]['Key']
|
|
master_secret = OPPOPUSH_CONFIG[appBundleId]['Secret']
|
|
master_secret = OPPOPUSH_CONFIG[appBundleId]['Secret']
|
|
@@ -883,7 +884,7 @@ class DevicePushService:
|
|
|
|
|
|
response = requests.post(push_url, data=push_data, headers=headers)
|
|
response = requests.post(push_url, data=push_data, headers=headers)
|
|
if response.status_code == 200:
|
|
if response.status_code == 200:
|
|
- if event_type in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
|
|
|
|
|
|
+ if event_type in DATA_PUSH_EVENT_TYPE_LIST:
|
|
PushObject.jpush_transparent_transmission(msg_title, msg_text, appBundleId, jg_token_val,
|
|
PushObject.jpush_transparent_transmission(msg_title, msg_text, appBundleId, jg_token_val,
|
|
extra_data)
|
|
extra_data)
|
|
return True
|
|
return True
|