|
@@ -13,6 +13,9 @@ from Object.ResponseObject import ResponseObject
|
|
|
from Service.PushService import PushObject
|
|
|
from AnsjerPush.config import XM_PUSH_CHANNEL_ID, HONORPUSH_CONFIG, LOGGER
|
|
|
from Service.HuaweiPushService.push_admin import messaging
|
|
|
+import logging
|
|
|
+
|
|
|
+ERROR_INFO_LOGGER = logging.getLogger('error_info')
|
|
|
|
|
|
|
|
|
class TransparentTransmissionPushView(View):
|
|
@@ -44,13 +47,14 @@ class TransparentTransmissionPushView(View):
|
|
|
return response.json(444)
|
|
|
try:
|
|
|
uid_push_qs = UidPushModel.objects.filter(userID=user_id, appBundleId=app_bundle_id).exclude(
|
|
|
- token_val=push_token).values('token_val', 'push_type', 'jg_token_val').distinct().order_by('token_val')
|
|
|
+ token_val=push_token).values('token_val', 'push_type', 'appBundleId',
|
|
|
+ 'jg_token_val').distinct().order_by('token_val')
|
|
|
if not uid_push_qs.exists():
|
|
|
return response.json(173)
|
|
|
uid_push_list = list(uid_push_qs)
|
|
|
LOGGER.info('{}推送列表:{}'.format(user_id, uid_push_list))
|
|
|
push_thread = threading.Thread(target=TransparentTransmissionPushView.thread_push,
|
|
|
- args=(uid_push_list, user_id, app_bundle_id, '强制登出', '强制登出', 705))
|
|
|
+ args=(uid_push_list, user_id, '强制登出', '强制登出', 705))
|
|
|
push_thread.start()
|
|
|
# 删除推送信息
|
|
|
UidPushModel.objects.filter(userID=user_id, appBundleId=app_bundle_id).exclude(
|
|
@@ -79,41 +83,46 @@ class TransparentTransmissionPushView(View):
|
|
|
return HttpResponse(repr(e), status=500)
|
|
|
|
|
|
@staticmethod
|
|
|
- def thread_push(qs, user_id, app_bundle_id, title, content, event_type):
|
|
|
- now_time = int(time.time())
|
|
|
- for push_item in qs:
|
|
|
- kwargs = {
|
|
|
- 'nickname': user_id,
|
|
|
- 'app_bundle_id': app_bundle_id,
|
|
|
- 'token_val': push_item['token_val'],
|
|
|
- 'n_time': now_time,
|
|
|
- 'event_type': event_type,
|
|
|
- 'msg_title': title,
|
|
|
- 'msg_text': content,
|
|
|
- }
|
|
|
- LOGGER.info('进入登出推送线程,参数:{}'.format(kwargs))
|
|
|
- if push_item['push_type'] == 0: # 苹果
|
|
|
- PushObject.ios_apns_push(**kwargs)
|
|
|
- elif push_item['push_type'] == 1: # 谷歌
|
|
|
- PushObject.android_fcm_push_v1(**kwargs)
|
|
|
- elif push_item['push_type'] == 2: # 极光
|
|
|
- PushObject.jpush_transparent_transmission(title, content, push_item['appBundleId'],
|
|
|
- push_item['token_val'], kwargs)
|
|
|
-
|
|
|
- elif push_item['push_type'] == 3: # 华为
|
|
|
- TransparentTransmissionPushView.huawei_transparent_transmission(user_id=user_id, **kwargs)
|
|
|
- elif push_item['push_type'] == 4: # 小米
|
|
|
- channel_id = XM_PUSH_CHANNEL_ID['device_reminder']
|
|
|
- PushObject.android_xmpush(channel_id=channel_id, **kwargs)
|
|
|
- elif push_item['push_type'] in [5, 6]: # vivo, oppo
|
|
|
- kwargs['token_val'] = push_item['jg_token_val']
|
|
|
- PushObject.jpush_transparent_transmission(title, content, push_item['appBundleId'],
|
|
|
- push_item['jg_token_val'], kwargs)
|
|
|
-
|
|
|
- elif push_item['push_type'] == 7: # 魅族
|
|
|
- PushObject.android_meizupush(**kwargs)
|
|
|
- elif push_item['push_type'] == 8: # 荣耀
|
|
|
- TransparentTransmissionPushView.honor_transparent_transmission(**kwargs)
|
|
|
+ def thread_push(push_list, user_id, title, content, event_type):
|
|
|
+ try:
|
|
|
+ now_time = int(time.time())
|
|
|
+ for push_item in push_list:
|
|
|
+ kwargs = {
|
|
|
+ 'nickname': user_id,
|
|
|
+ 'app_bundle_id': push_item['appBundleId'],
|
|
|
+ 'token_val': push_item['token_val'],
|
|
|
+ 'n_time': now_time,
|
|
|
+ 'event_type': event_type,
|
|
|
+ 'msg_title': title,
|
|
|
+ 'msg_text': content,
|
|
|
+ }
|
|
|
+ LOGGER.info('进入登出推送线程,参数:{}'.format(kwargs))
|
|
|
+ if push_item['push_type'] == 0: # 苹果
|
|
|
+ PushObject.ios_apns_push(**kwargs)
|
|
|
+ elif push_item['push_type'] == 1: # 谷歌
|
|
|
+ PushObject.android_fcm_push_v1(**kwargs)
|
|
|
+ elif push_item['push_type'] == 2: # 极光
|
|
|
+ PushObject.jpush_transparent_transmission(title, content, push_item['appBundleId'],
|
|
|
+ push_item['token_val'], kwargs)
|
|
|
+
|
|
|
+ elif push_item['push_type'] == 3: # 华为
|
|
|
+ TransparentTransmissionPushView.huawei_transparent_transmission(user_id=user_id, **kwargs)
|
|
|
+ elif push_item['push_type'] == 4: # 小米
|
|
|
+ channel_id = XM_PUSH_CHANNEL_ID['device_reminder']
|
|
|
+ PushObject.android_xmpush(channel_id=channel_id, **kwargs)
|
|
|
+ elif push_item['push_type'] in [5, 6]: # vivo, oppo
|
|
|
+ kwargs['token_val'] = push_item['jg_token_val']
|
|
|
+ PushObject.jpush_transparent_transmission(title, content, push_item['appBundleId'],
|
|
|
+ push_item['jg_token_val'], kwargs)
|
|
|
+
|
|
|
+ elif push_item['push_type'] == 7: # 魅族
|
|
|
+ PushObject.android_meizupush(**kwargs)
|
|
|
+ elif push_item['push_type'] == 8: # 荣耀
|
|
|
+ TransparentTransmissionPushView.honor_transparent_transmission(**kwargs)
|
|
|
+ except Exception as e:
|
|
|
+ ERROR_INFO_LOGGER.info(
|
|
|
+ 'TransparentTransmissionPushView推送线程异常:errLine:{}, errMsg:{}, 参数:{}'.format(e.__traceback__.tb_lineno,
|
|
|
+ repr(e), push_list))
|
|
|
|
|
|
@staticmethod
|
|
|
def huawei_transparent_transmission(nickname, app_bundle_id, token_val, n_time, event_type, msg_title,
|