Browse Source

Merge branch 'test' of http://192.168.136.99:3000/servers/ASJServer into peng

peng 9 months ago
parent
commit
9e162b269f
4 changed files with 32 additions and 35 deletions
  1. 2 2
      Ansjer/config.py
  2. 24 19
      Controller/EquipmentManager.py
  3. 1 0
      Controller/InAppPurchaseController.py
  4. 5 14
      Object/TokenObject.py

+ 2 - 2
Ansjer/config.py

@@ -81,9 +81,9 @@ OAUTH_ACCESS_TOKEN_SECRET = 'a+jbgnw%@1%zy^=@dn62%'
 OAUTH_REFRESH_TOKEN_SECRET = 'r+jbgnw%@1%zy^=@dn62%'
 
 # access_token超时
-OAUTH_ACCESS_TOKEN_TIME = datetime.timedelta(days=30)
+OAUTH_ACCESS_TOKEN_TIME = datetime.timedelta(days=60)
 # refresh_token超时
-OAUTH_REFRESH_TOKEN_TIME = datetime.timedelta(days=30)
+OAUTH_REFRESH_TOKEN_TIME = datetime.timedelta(days=60)
 # 腾讯验证,短信发送
 TX_PHONE_APP_ID = '1400052907'
 TX_PHONE_APP_KEY = '7705976ca6e85fe7b86d6bc2d11f7783'

+ 24 - 19
Controller/EquipmentManager.py

@@ -1148,26 +1148,31 @@ def uid_status(request):
             'msgData': qs[0]['msg_notify']
         }
 
-        # 检查 channel 有效性和 msg_notify 是否存在
-        if channel > 0 and is_nvr == 1 and qs[0].get('msg_notify'):
-            # 获取 msg_notify 数据
-            msg_notify = qs[0]['msg_notify']
-            nvr_entries = msg_notify.get('nvr', [])
-            channel_key = f'channel{channel}'
-
-            # 查找匹配的 channel_entry
-            matching_entry = next((entry for entry in nvr_entries if channel_key in entry), None)
-
-            if matching_entry:
-                # 更新 nvr 值
-                data['msgData']['nvr'] = matching_entry[channel_key]
+        try:
+            # 检查 channel 有效性和 msg_notify 是否存在
+            if channel > 0 and is_nvr == 1 and qs[0].get('msg_notify'):
+                # 获取 msg_notify 数据
+                msg_notify = qs[0]['msg_notify']
+                nvr_entries = msg_notify.get('nvr', [])
+                channel_key = f'channel{channel}'
+
+                # 查找匹配的 channel_entry
+                matching_entry = next((entry for entry in nvr_entries if channel_key in entry), None)
+
+                if matching_entry:
+                    # 更新 nvr 值
+                    data['msgData']['nvr'] = matching_entry[channel_key]
+                else:
+                    # 没有找到匹配的 channel,使用默认值替换 nvr
+                    available_types = [t for t in ALGORITHM_COMBO_TYPES if t != 51]
+                    data['msgData']['nvr'] = available_types
             else:
-                # 没有找到匹配的 channel,使用默认值替换 nvr
-                available_types = [t for t in ALGORITHM_COMBO_TYPES if t != 51]
-                data['msgData']['nvr'] = available_types
-        else:
-            if 'nvr' in qs[0].get('msg_notify'):
-                data['msgData']['nvr'] = []
+                msg_notify = qs[0].get('msg_notify')
+                if msg_notify and 'nvr' in msg_notify:
+                    data['msgData']['nvr'] = []
+        except Exception as e:
+            logger.error(f'查询消息提醒异常uid:{uid},error:{repr(e)}')
+
 
         # 调试
         debugTwos = int(time.time())

+ 1 - 0
Controller/InAppPurchaseController.py

@@ -148,6 +148,7 @@ class InAppPurchaseView(View):
             while attempts < 6:
                 try:
                     transaction_info = client.get_transaction_info(transaction_id)
+                    break
                 except ConnectionError as err:
                     attempts += 1
                     if attempts == 5:

+ 5 - 14
Object/TokenObject.py

@@ -1,4 +1,3 @@
-import datetime
 import logging
 import jwt
 import time
@@ -6,7 +5,7 @@ import requests
 
 from Object.RedisObject import RedisObject
 from Ansjer.config import OAUTH_ACCESS_TOKEN_SECRET, OAUTH_REFRESH_TOKEN_SECRET, OAUTH_ACCESS_TOKEN_TIME, \
-    OAUTH_REFRESH_TOKEN_TIME, CONFIG_INFO, CONFIG_TEST, CONFIG_CN, DETECT_PUSH_DOMAINS, LOGGER
+    OAUTH_REFRESH_TOKEN_TIME, DETECT_PUSH_DOMAINS, LOGGER
 
 logger = logging.getLogger('token')
 
@@ -83,12 +82,8 @@ class TokenObject:
         if data is None:
             data = {}
         try:
-            if CONFIG_INFO == CONFIG_TEST or CONFIG_INFO == CONFIG_CN:
-                access_expire = int(datetime.timedelta(days=60).total_seconds())
-                refresh_expire = int(datetime.timedelta(days=60).total_seconds())
-            else:
-                access_expire = int(OAUTH_ACCESS_TOKEN_TIME.total_seconds())
-                refresh_expire = int(OAUTH_REFRESH_TOKEN_TIME.total_seconds())
+            access_expire = int(OAUTH_ACCESS_TOKEN_TIME.total_seconds())
+            refresh_expire = int(OAUTH_REFRESH_TOKEN_TIME.total_seconds())
             now_stamp = int(time.time())
             access_data = data
             refresh_data = data
@@ -144,12 +139,8 @@ class TokenObject:
         if data is None:
             data = {}
         try:
-            if CONFIG_INFO == CONFIG_TEST or CONFIG_INFO == CONFIG_CN:
-                access_expire = int(datetime.timedelta(days=60).total_seconds())
-                refresh_expire = int(datetime.timedelta(days=60).total_seconds())
-            else:
-                access_expire = int(OAUTH_ACCESS_TOKEN_TIME.total_seconds())
-                refresh_expire = int(OAUTH_REFRESH_TOKEN_TIME.total_seconds())
+            access_expire = int(OAUTH_ACCESS_TOKEN_TIME.total_seconds())
+            refresh_expire = int(OAUTH_REFRESH_TOKEN_TIME.total_seconds())
             now_stamp = int(time.time())
             access_data = data
             refresh_data = data