|
@@ -383,17 +383,34 @@ class NotificationView(View):
|
|
|
push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
|
|
|
"received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
|
|
|
n_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(n_time)))
|
|
|
+ # if lang == 'cn':
|
|
|
+ # if nickname:
|
|
|
+ # message_title = "周视({nickname})".format(nickname=nickname)
|
|
|
+ # else:
|
|
|
+ # message_title = "周视({uid})".format(uid=uid)
|
|
|
+ # send_text = '通道:{channel} 日期:{date}'.format(channel=channel, date=n_date)
|
|
|
+ # else:
|
|
|
+ # if nickname:
|
|
|
+ # message_title = "zosi({nickname})".format(nickname=nickname)
|
|
|
+ # else:
|
|
|
+ # message_title = "zosi({uid})".format(uid=uid)
|
|
|
+ # send_text = 'channel:{channel} date:{date}'.format(channel=channel, date=n_date)
|
|
|
if lang == 'cn':
|
|
|
if nickname:
|
|
|
- message_title = "周视({nickname})".format(nickname=nickname)
|
|
|
+ # message_title = "周视({nickname})".format(nickname=nickname)
|
|
|
+ message_title = self.get_message_title(appBundleId=appBundleId, nickname=nickname)
|
|
|
else:
|
|
|
- message_title = "周视({uid})".format(uid=uid)
|
|
|
+ # message_title = "周视({uid})".format(uid=uid)
|
|
|
+ message_title = self.get_message_title(appBundleId=appBundleId, nickname=uid)
|
|
|
send_text = '通道:{channel} 日期:{date}'.format(channel=channel, date=n_date)
|
|
|
else:
|
|
|
if nickname:
|
|
|
- message_title = "zosi({nickname})".format(nickname=nickname)
|
|
|
+ message_title = self.get_message_title(appBundleId=appBundleId, nickname=nickname)
|
|
|
+ # message_title = "zosi({nickname})".format(nickname=nickname)
|
|
|
else:
|
|
|
- message_title = "zosi({uid})".format(uid=uid)
|
|
|
+ message_title = self.get_message_title(appBundleId=appBundleId, nickname=uid)
|
|
|
+
|
|
|
+ # message_title = "zosi({uid})".format(uid=uid)
|
|
|
send_text = 'channel:{channel} date:{date}'.format(channel=channel, date=n_date)
|
|
|
android = jpush.android(alert=send_text, priority=1, style=1, alert_type=7,
|
|
|
big_text=send_text, title=message_title,
|
|
@@ -412,39 +429,25 @@ class NotificationView(View):
|
|
|
else:
|
|
|
return response.json(0)
|
|
|
|
|
|
- '''
|
|
|
- def do_gmc(self, request_dict, uaql, response, uid, channel):
|
|
|
|
|
|
- n_time = request_dict.get('n_time')
|
|
|
- appBundleId = uaql['appBundleId']
|
|
|
- token_val = uaql['token_val']
|
|
|
- gcm_config = {
|
|
|
- 'com.ansjer.zccloud_a': 'AAAAb9YP3rk:APA91bHu8u-CTpcd0g6lKPo0WNVqCi8jZub1cPPbSAY9AucT1HxlF65ZDUko9iG8q2ch17bwu9YWHpK1xI1gHSRXCslLvZlXEmHZC0AG3JKg15XuUvlFKACIajUFV-pOeGRT8tM6-31I',
|
|
|
- 'com.ansjer.loocamccloud_a': 'AAAAb9YP3rk:APA91bFCgd-kbVmpK4EVpfdHH_PJZQCYTkOGnTZdIuBWEz2r7aMRsJYHOH3sB-rwcbaRWgnufTyjX9nGQxb6KxQbWVk4ah_H-M3IqGh6Mb60WQQAuR33V6g_Jes5pGL6ViuIxGHqVMaR',
|
|
|
- 'com.ansjer.loocamdcloud_a': 'AAAAb9YP3rk:APA91bGw2I2KMD4i-5T7nZO_wB8kuAOuqgyqe5rxmY-W5qkpYEx9IL2IfmC_qf6B_xOyjIDDSjckvMo-RauN__SEoxvAkis7042GRkoKpw7cjZ_H8lC-d50PC0GclPzccrOGFusyKbFY',
|
|
|
- 'com.ansjer.customizedb_a': 'AAAAb9YP3rk:APA91bE7kI4vcm-9h_CJNFlOZfc-xwP4Btn6AnjOrwoKV6fgYN7fdarkO76sYxVZiAbDnxsFfOJyP7vQfwyan6mdjuyD5iHdt_XgO22VqniC0vA1V4GJiCS8Tp7LxIX8JVKZl9I_Powt',
|
|
|
- 'com.ansjer.customizeda_a': 'AAAAb9YP3rk:APA91bF0HzizVWDc6dKzobY9fsaKDK4veqkOZehDXshVXs8pEEvNWjR_YWbhP60wsRYCHCal8fWN5cECVOWNMMzDsfU88Ty2AUl8S5FtZsmeDTkoGntQOswBr8Ln7Fm_LAp1VqTf9CpM',
|
|
|
- }
|
|
|
- serverKey = gcm_config[appBundleId]
|
|
|
- event_type = request_dict.get('event_type', None)
|
|
|
- push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
|
|
|
- "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1"}
|
|
|
- json_data = {
|
|
|
- "collapse_key": "WhatYouWant",
|
|
|
- "data": push_data,
|
|
|
- "delay_while_idle": False,
|
|
|
- "time_to_live": 3600,
|
|
|
- "registration_ids": [token_val]
|
|
|
+ def get_message_title(self, appBundleId, nickname):
|
|
|
+ package_title_config = {
|
|
|
+ 'com.ansjer.customizedd_a':'DVS',
|
|
|
+ 'com.ansjer.zccloud_a':'ZosiSmart',
|
|
|
+ 'com.ansjer.zccloud_ab':'周视',
|
|
|
+ 'com.ansjer.adcloud_a':'ADCloud',
|
|
|
+ 'com.ansjer.adcloud_ab':'ADCloud',
|
|
|
+ 'com.ansjer.accloud_a':'ACCloud',
|
|
|
+ 'com.ansjer.loocamccloud_a':'Loocam',
|
|
|
+ 'com.ansjer.loocamdcloud_a':'Anlapus',
|
|
|
+ 'com.ansjer.customizedb_a':'COCOONHD',
|
|
|
+ 'com.ansjer.customizeda_a':'Guardian365',
|
|
|
+ 'com.ansjer.customizedc_a':'PatrolSecure',
|
|
|
}
|
|
|
-
|
|
|
- url = 'https://android.googleapis.com/gcm/send'
|
|
|
- # serverKey = "AAAAb9YP3rk:APA91bHu8u-CTpcd0g6lKPo0WNVqCi8jZub1cPPbSAY9AucT1HxlF65ZDUko9iG8q2ch17bwu9YWHpK1xI1gHSRXCslLvZlXEmHZC0AG3JKg15XuUvlFKACIajUFV-pOeGRT8tM6-31I"
|
|
|
-
|
|
|
- data = json.dumps(json_data).encode('utf-8')
|
|
|
- headers = {'Content-Type': 'application/json', 'Authorization': 'key=%s' % serverKey}
|
|
|
- req = requests.post(url, data, headers=headers)
|
|
|
- return response.json(0)
|
|
|
- '''
|
|
|
+ if appBundleId in package_title_config.keys():
|
|
|
+ return package_title_config[appBundleId]+'('+nickname+')'
|
|
|
+ else:
|
|
|
+ return nickname
|
|
|
|
|
|
def do_fcm(self, request_dict, uaql, response, uid, channel, nickname):
|
|
|
n_time = request_dict.get('n_time')
|
|
@@ -471,15 +474,20 @@ class NotificationView(View):
|
|
|
n_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(n_time)))
|
|
|
if lang == 'cn':
|
|
|
if nickname:
|
|
|
- message_title = "周视({nickname})".format(nickname=nickname)
|
|
|
+ # message_title = "周视({nickname})".format(nickname=nickname)
|
|
|
+ message_title = self.get_message_title(appBundleId=appBundleId,nickname=nickname)
|
|
|
else:
|
|
|
- message_title = "周视({uid})".format(uid=uid)
|
|
|
+ # message_title = "周视({uid})".format(uid=uid)
|
|
|
+ message_title = self.get_message_title(appBundleId=appBundleId,nickname=uid)
|
|
|
send_text = '通道:{channel} 日期:{date}'.format(channel=channel, date=n_date)
|
|
|
else:
|
|
|
if nickname:
|
|
|
- message_title = "zosi({nickname})".format(nickname=nickname)
|
|
|
+ message_title = self.get_message_title(appBundleId=appBundleId,nickname=nickname)
|
|
|
+ # message_title = "zosi({nickname})".format(nickname=nickname)
|
|
|
else:
|
|
|
- message_title = "zosi({uid})".format(uid=uid)
|
|
|
+ message_title = self.get_message_title(appBundleId=appBundleId,nickname=uid)
|
|
|
+
|
|
|
+ # message_title = "zosi({uid})".format(uid=uid)
|
|
|
send_text = 'channel:{channel} date:{date}'.format(channel=channel, date=n_date)
|
|
|
data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
|
|
|
"received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
|