|
@@ -19,7 +19,7 @@ import requests
|
|
|
from pyfcm import FCMNotification
|
|
|
|
|
|
from AnsjerPush.config import JPUSH_CONFIG, FCM_CONFIG, APNS_CONFIG, BASE_DIR, APNS_MODE, APP_BUNDLE_DICT, \
|
|
|
- XMPUSH_CONFIG, VIVOPUSH_CONFIG, OPPOPUSH_CONFIG
|
|
|
+ XMPUSH_CONFIG, VIVOPUSH_CONFIG, OPPOPUSH_CONFIG, MEIZUPUSH_CONFIG
|
|
|
from AnsjerPush.config import SERVER_TYPE
|
|
|
from Model.models import UidPushModel, SysMsgModel, DeviceSharePermission, DeviceChannelUserSet, \
|
|
|
DeviceChannelUserPermission
|
|
@@ -167,7 +167,7 @@ class DevicePushService:
|
|
|
try:
|
|
|
kwag_args = param['kwag_args']
|
|
|
result = {'do_apns_code': '', 'do_fcm_code': '', 'do_jpush_code': '', 'do_xmpush_code': '',
|
|
|
- 'do_vivopush_code': ''}
|
|
|
+ 'do_vivopush_code': '', 'do_meizupush_code': ''}
|
|
|
# 判断是否进行APP消息推送,如app_push不为空,则不进行推送
|
|
|
if not param['app_push']:
|
|
|
LOGGING.info('APP准备推送:{}, {}'.format(param['uid'], param))
|
|
@@ -193,9 +193,11 @@ class DevicePushService:
|
|
|
elif push_type == 4: # android xmpush
|
|
|
result['do_xmpush_code'] = cls.do_xmpush(**kwag_args)
|
|
|
elif push_type == 5: # android vivopush
|
|
|
- result['do_vivopush_code'] = cls.do_vivopush(**kwag_args)
|
|
|
+ result['do_vivopush_code'] = PushObject.android_meizupush(**kwag_args)
|
|
|
elif push_type == 6: # android oppopush
|
|
|
result['do_oppopush_code'] = cls.do_oppopush(**kwag_args)
|
|
|
+ elif push_type == 7: # android meizupush
|
|
|
+ result['do_meizupush_code'] = PushObject.android_meizupush(**kwag_args)
|
|
|
return result
|
|
|
except Exception as e:
|
|
|
LOGGING.info('异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
@@ -470,9 +472,15 @@ class DevicePushService:
|
|
|
elif push_type == 4:
|
|
|
PushObject.android_xmpush(uid, appBundleId, token_val, n_time, event_type, msg_title,
|
|
|
msg_text, uid, channel, image_url)
|
|
|
+ elif push_type == 5:
|
|
|
+ PushObject.android_meizupush(uid, appBundleId, token_val, n_time, event_type, msg_title,
|
|
|
+ msg_text, uid, channel, image_url)
|
|
|
elif push_type == 6:
|
|
|
PushObject.android_oppopush(uid, appBundleId, token_val, n_time, event_type, msg_title,
|
|
|
msg_text, uid, channel, image_url)
|
|
|
+ elif push_type == 7:
|
|
|
+ PushObject.android_meizupush(uid, appBundleId, token_val, n_time, event_type, msg_title,
|
|
|
+ msg_text, uid, channel, image_url)
|
|
|
except Exception as e:
|
|
|
LOGGING.info('异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
@@ -495,7 +503,9 @@ class DevicePushService:
|
|
|
elif up['push_type'] == 4: # android jpush
|
|
|
up['do_xmpush_code'] = params['code_dict']['code_date']['do_xmpush_code']
|
|
|
elif up['push_type'] == 5: # android jpush
|
|
|
- up['do_vivopush_code'] = params['code_dict']['code_date']['do_xmpush_code']
|
|
|
+ up['do_vivopush_code'] = params['code_dict']['code_date']['do_vivopush_code']
|
|
|
+ elif up['push_type'] == 7: # android jpush
|
|
|
+ up['do_meizupush_code'] = params['code_dict']['code_date']['do_meizupush_code']
|
|
|
del up['push_type']
|
|
|
del up['userID_id']
|
|
|
del up['userID__NickName']
|
|
@@ -570,50 +580,3 @@ class DevicePushService:
|
|
|
if not channel_permission_qs.exists():
|
|
|
return False
|
|
|
return True
|
|
|
-
|
|
|
- @classmethod
|
|
|
- def do_vivopush(cls, uid, channel, appBundleId, token_val, event_type, n_time,
|
|
|
- msg_title, msg_text):
|
|
|
- logger = logging.getLogger('info')
|
|
|
- try:
|
|
|
- authToken = 'authToken_' + appBundleId
|
|
|
- redisObj = RedisObject()
|
|
|
- # 获取redis里面的authToken
|
|
|
- redis_authToken = redisObj.get_data(key=authToken)
|
|
|
- if msg_title == '':
|
|
|
- msg_title = '周视'
|
|
|
- if redis_authToken is not False:
|
|
|
- app_secret = VIVOPUSH_CONFIG[appBundleId]['Secret']
|
|
|
- sender_send = APISender(app_secret)
|
|
|
- sender_send.set_token(redis_authToken)
|
|
|
- else:
|
|
|
- app_id = VIVOPUSH_CONFIG[appBundleId]['ID']
|
|
|
- app_key = VIVOPUSH_CONFIG[appBundleId]['Key']
|
|
|
- app_secret = VIVOPUSH_CONFIG[appBundleId]['Secret']
|
|
|
- sender = APISender(app_secret)
|
|
|
- rec = sender.get_token(app_id, app_key)
|
|
|
- # 存放authToken,有效期3个小时
|
|
|
- redisObj = RedisObject()
|
|
|
- redisObj.set_data(key=authToken, val=rec['authToken'], expire=10800)
|
|
|
- sender_send = APISender(app_secret)
|
|
|
- sender_send.set_token(rec['authToken'])
|
|
|
- push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
|
|
|
- 'received_at': n_time, 'event_time': n_time, 'event_type': event_type,
|
|
|
- 'uid': uid, 'channel': channel
|
|
|
- }
|
|
|
- # 推送
|
|
|
- message = PushMessage() \
|
|
|
- .reg_id(token_val) \
|
|
|
- .title(msg_title) \
|
|
|
- .content(msg_text) \
|
|
|
- .push_mode(1) \
|
|
|
- .notify_type(1) \
|
|
|
- .skip_type('1') \
|
|
|
- .request_id('123456') \
|
|
|
- .classification(1) \
|
|
|
- .client_custom_map(**push_data) \
|
|
|
- .message_dict()
|
|
|
- rec2 = sender_send.send(message)
|
|
|
- logger.info('vivo推送结果:{}'.format(rec2))
|
|
|
- except Exception as e:
|
|
|
- logger.info('vivo推送异常:{}'.format(e))
|