Browse Source

荣耀一键通话增加通知推送

locky 1 year ago
parent
commit
1a37ac125a
1 changed files with 21 additions and 12 deletions
  1. 21 12
      Service/PushService.py

+ 21 - 12
Service/PushService.py

@@ -522,23 +522,32 @@ class PushObject:
                           'received_at': n_time, 'event_time': n_time, 'event_type': str(event_type), 'nickname': nickname,
                           'uid': uid, 'channel': channel, 'title': msg_title, 'body': msg_text
                           }
+
+            # 一键通话通知推送
+            if event_type in [606, 607]:
+                push_data = {
+                    "android": {
+                        "data": json.dumps(extra_data),
+                        "notification": {
+                            "body": msg_text,
+                            "title": msg_title,
+                            "clickAction": {
+                                "type": 3
+                            }
+                        }
+                    },
+                    "token": [token_val]
+                }
+                response = requests.post(push_url, json=push_data, headers=headers)
+                LOGGER.info("uid{}时间{},荣耀通知推送返回值:{}".format(uid, n_time, response.json()))
+
+            # 透传推送
             push_data = {
-                "android": {
-                    # "data": json.dumps(extra_data),
-                    # "notification": {
-                    #     "body": msg_text,
-                    #     "title": msg_title,
-                    #     "clickAction": {
-                    #         "type": 3
-                    #     }
-                    # }
-                },
                 "data": json.dumps(extra_data),
-                "notification": {},
                 "token": [token_val]
             }
             response = requests.post(push_url, json=push_data, headers=headers)
-            LOGGER.info("uid{}时间{},荣耀推送返回值:{}".format(uid, n_time, response.json()))
+            LOGGER.info("uid{}时间{},荣耀透传推送返回值:{}".format(uid, n_time, response.json()))
             return True
         except Exception as e:
             LOGGER.info("荣耀推送异常:error_line:{},error_msg:{}".format(e.__traceback__.tb_lineno, repr(e)))