|
@@ -189,7 +189,7 @@ class PushObject:
|
|
|
@param msg_title: 推送标题
|
|
|
@param msg_text: 推送内容
|
|
|
@param channel: 设备通道
|
|
|
- @return: None
|
|
|
+ @return: bool
|
|
|
"""
|
|
|
try:
|
|
|
app_key = JPUSH_CONFIG[app_bundle_id]['Key']
|
|
@@ -209,8 +209,10 @@ class PushObject:
|
|
|
push.platform = jpush.all_
|
|
|
res = push.send()
|
|
|
assert res.status_code == 200
|
|
|
+ return True
|
|
|
except Exception as e:
|
|
|
LOGGER.info('极光推送异常:{}'.format(repr(e)))
|
|
|
+ return False
|
|
|
|
|
|
@staticmethod
|
|
|
def android_xmpush(channel_id, nickname, app_bundle_id, token_val, n_time, event_type, msg_title, msg_text,
|
|
@@ -228,9 +230,8 @@ class PushObject:
|
|
|
@param uid: uid
|
|
|
@param channel: 通道
|
|
|
@param image: 推送图片链接
|
|
|
- @return: None
|
|
|
+ @return: bool
|
|
|
"""
|
|
|
- logger = logging.getLogger('info')
|
|
|
try:
|
|
|
url = 'https://api.xmpush.xiaomi.com/v3/message/regid'
|
|
|
app_secret = XMPUSH_CONFIG[app_bundle_id]
|
|
@@ -263,10 +264,12 @@ class PushObject:
|
|
|
'Authorization': 'key={}'.format(app_secret)
|
|
|
}
|
|
|
response = requests.post(url, data=data, headers=headers)
|
|
|
- logger.info("小米推送返回值:{}".format(response.json()))
|
|
|
+ LOGGER.info("小米推送返回值:{}".format(response.json()))
|
|
|
assert response.status_code == 200
|
|
|
+ return True
|
|
|
except Exception as e:
|
|
|
- return repr(e)
|
|
|
+ LOGGER.info("小米推送异常:{}".format(repr(e)))
|
|
|
+ return False
|
|
|
|
|
|
@staticmethod
|
|
|
def android_vivopush(token_val, n_time, event_type, msg_title, msg_text, app_bundle_id='', uid='', channel='1',
|
|
@@ -285,9 +288,8 @@ class PushObject:
|
|
|
@param uid: uid
|
|
|
@param image: 推送图片链接
|
|
|
@param channel: 通道
|
|
|
- @return: None
|
|
|
+ @return: bool
|
|
|
"""
|
|
|
- logger = logging.getLogger('info')
|
|
|
try:
|
|
|
app_bundle_id = app_bundle_id if app_bundle_id != '' else appBundleId
|
|
|
# 获取redis里面的authToken
|
|
@@ -325,12 +327,13 @@ class PushObject:
|
|
|
.client_custom_map(**push_data) \
|
|
|
.message_dict()
|
|
|
rec = sender_send.send(message)
|
|
|
- logger.info('vivo推送结果:{}, 设备uid:{}'.format(rec, uid))
|
|
|
+ LOGGER.info('vivo推送结果:{}, 设备uid:{}'.format(rec, uid))
|
|
|
if rec['result'] == 0 and event_type in [606, 607]:
|
|
|
PushObject.jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, jg_token_val, push_data)
|
|
|
- return rec
|
|
|
+ return True
|
|
|
except Exception as e:
|
|
|
- logger.info('vivo推送异常:{}'.format(e))
|
|
|
+ LOGGER.info('vivo推送异常:{}'.format(e))
|
|
|
+ return False
|
|
|
|
|
|
@staticmethod
|
|
|
def android_oppopush(channel_id, nickname, app_bundle_id, token_val, n_time, event_type, msg_title, msg_text,
|
|
@@ -349,9 +352,8 @@ class PushObject:
|
|
|
@param uid: uid
|
|
|
@param channel: 通道
|
|
|
@param image: 推送图片链接
|
|
|
- @return: None
|
|
|
+ @return: bool
|
|
|
"""
|
|
|
- logger = logging.getLogger('info')
|
|
|
try:
|
|
|
"""
|
|
|
android 国内oppo APP消息提醒推送
|
|
@@ -400,11 +402,13 @@ class PushObject:
|
|
|
}
|
|
|
|
|
|
response = requests.post(push_url, data=push_data, headers=headers)
|
|
|
- logger.info("oppo推送返回值:{}".format(response.json()))
|
|
|
+ LOGGER.info("oppo推送返回值:{}".format(response.json()))
|
|
|
if response.status_code == 200 and event_type in [606, 607]:
|
|
|
PushObject.jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, jg_token_val, extra_data)
|
|
|
+ return True
|
|
|
except Exception as e:
|
|
|
- return repr(e)
|
|
|
+ LOGGER.info("oppo推送异常:{}".format(repr(e)))
|
|
|
+ return False
|
|
|
|
|
|
@staticmethod
|
|
|
def android_meizupush(token_val, n_time, event_type, msg_title, msg_text, uid='', channel='1',
|
|
@@ -422,9 +426,8 @@ class PushObject:
|
|
|
@param uid: uid
|
|
|
@param image: 推送图片链接
|
|
|
@param channel: 通道
|
|
|
- @return: None
|
|
|
+ @return: bool
|
|
|
"""
|
|
|
- logger = logging.getLogger('info')
|
|
|
try:
|
|
|
# 获取包和AppSecret
|
|
|
app_bundle_id = app_bundle_id if app_bundle_id != '' else appBundleId
|
|
@@ -463,10 +466,11 @@ class PushObject:
|
|
|
}
|
|
|
# 进行推送
|
|
|
response = requests.post(url, data=data)
|
|
|
- logger.info("魅族推送结果:{}".format(response.json()))
|
|
|
- return response.status_code
|
|
|
+ LOGGER.info("魅族推送结果:{}".format(response.json()))
|
|
|
+ return True
|
|
|
except Exception as e:
|
|
|
- return repr(e)
|
|
|
+ LOGGER.info("魅族推送异常:{}".format(repr(e)))
|
|
|
+ return False
|
|
|
|
|
|
@staticmethod
|
|
|
def jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, token_val, extra_data):
|