Bläddra i källkod

移除推送阿里云配额相关代码

locky 2 veckor sedan
förälder
incheckning
d2d246d5de

+ 0 - 4
AnsjerPush/config.py

@@ -30,10 +30,6 @@ JPUSH_UID_LIST = 'jpush_uid_list'
 HUAWEICLOUD_OBS_SERVER = 'https://obs.cn-east-3.myhuaweicloud.com'
 HUAWEICLOUD_PUSH_BUKET = 'asj-push'
 
-# 阿里云存储每日配额限制(测试/国内服)
-# 优先从 Redis 的 'push:alicloud:daily:quota:limit' 读取,如果 Redis 中未设置则使用此默认值
-ALICLOUD_OSS_DAILY_QUOTA = 10000  # 默认每天1万条
-
 # 阿里云发邮箱
 ALY_SES_ACCESS_NAME = 'message@dvema.com'
 ALY_SES_ACCESS_PAW = 'SMtp123456'

+ 1 - 16
Controller/DetectControllerV2.py

@@ -150,18 +150,11 @@ class NotificationV2View(View):
                     storage_location = int(storage_location)
                 else:
                     storage_location = 1  # 默认阿里云
-                
-                # 阿里云存储配额控制:如果是阿里云(storage_location=1)且配额已满,则降级到AWS
-                if storage_location == 1:
-                    if not DevicePushService.check_and_use_alicloud_quota(redis_obj, uid, event_type):
-                        # 配额已满,降级到AWS
-                        storage_location = 2
-                        TIME_LOGGER.info('阿里云配额已满,uid:{},降级到AWS'.format(uid))
             else:
                 if storage_location is not None:
                     storage_location = int(storage_location)
                 else:
-                    storage_location = 2
+                    storage_location = 1
 
             params = {'nickname': nickname, 'uid': uid, 'push_kwargs': push_kwargs, 'is_st': is_st, 'region': region,
                       'is_sys_msg': is_sys_msg, 'channel': channel, 'event_type': event_type, 'n_time': n_time,
@@ -172,10 +165,6 @@ class NotificationV2View(View):
                       'app_push_config': uid_set_push_list[0]['uid_set__msg_notify'],
                       'uid_set_push_list': uid_set_push_list, 'redis_obj': redis_obj}
 
-            # 使用全局的线程池提交推送任务
-            # thread_pool = GlobalThreadPool()
-            # thread_pool.submit(push_and_save_data, **params)
-
             # 异步推送消息和保存数据
             push_thread = threading.Thread(
                 target=push_and_save_data,
@@ -217,10 +206,6 @@ def push_and_save_data(**params):
     try:
         TIME_LOGGER.info('{}开始异步存表和推送'.format(uid))
 
-        # 线程池推送消息
-        # thread_pool = GlobalThreadPool()
-        # thread_pool.submit(DevicePushService.push_msg, **params)
-
         # 异步推送消息
         push_thread = threading.Thread(
             target=DevicePushService.push_msg,

+ 1 - 5
Object/enums/RedisKeyConstant.py

@@ -3,8 +3,4 @@ from enum import Enum
 
 class RedisKeyConstant(Enum):
     # 设备版本信息
-    PUSH_STORAGE_CONFIG_UID = 'push:storage:config:uid:'
-    # 阿里云存储每日配额计数器
-    ALICLOUD_DAILY_QUOTA_COUNTER = 'push:alicloud:daily:quota:counter:'
-    # 阿里云存储每日配额限制值
-    ALICLOUD_DAILY_QUOTA_LIMIT = 'push:alicloud:daily:quota:limit'
+    PUSH_STORAGE_CONFIG_UID = 'push:storage:config:uid:'

+ 1 - 53
Service/DevicePushService.py

@@ -26,7 +26,7 @@ from AnsjerPush.MessageConfig import EVENT_CONFIGS, DEFAULT_TEXTS, MSG_CONFIG
 from AnsjerPush.config import CONFIG_INFO, CONFIG_CN, MULTI_CHANNEL_TYPE_LIST, SYS_EVENT_TYPE_LIST, \
     EVENT_DICT, EVENT_DICT_CN, CONFIG_TEST, \
     HUAWEICLOUD_OBS_SERVER, HUAWEICLOUD_PUSH_BUKET, JPUSH_UID_LIST, \
-    DATA_PUSH_EVENT_TYPE_LIST, PRIMARY_USERS_PUSH_EVENT_TYPE_LIST, BASE_STATION_TYPE_LIST, ALICLOUD_OSS_DAILY_QUOTA
+    DATA_PUSH_EVENT_TYPE_LIST, PRIMARY_USERS_PUSH_EVENT_TYPE_LIST, BASE_STATION_TYPE_LIST
 from AnsjerPush.config import XMPUSH_CONFIG, OPPOPUSH_CONFIG, XM_PUSH_CHANNEL_ID, XM_PUSH_CHANNEL_DICT
 from Model.models import UidPushModel, SysMsgModel, DeviceSharePermission, DeviceChannelUserSet, \
     DeviceChannelUserPermission, UidSetModel, Device_Info, UserAudioVideoPush, PushLog, TimeAlbum, AlbumMedia, \
@@ -37,7 +37,6 @@ from Object.RedisObject import RedisObject
 from Object.UidTokenObject import UidTokenObject
 from Object.enums.ConstantEnum import ConstantEnum
 from Object.enums.EventTypeEnum import EventTypeEnumObj
-from Object.enums.RedisKeyConstant import RedisKeyConstant
 from Object.utils import LocalDateTimeUtil
 from Service.CommonService import CommonService
 from Service.EquipmentInfoService import EquipmentInfoService, EQUIPMENT_INFO_DICT
@@ -1135,57 +1134,6 @@ class DevicePushService:
             return ''
         return result.full_path + result.object_name
 
-    @staticmethod
-    def check_and_use_alicloud_quota(redis_obj, uid, event_type):
-        """
-        检查并使用阿里云存储配额
-        @param redis_obj: Redis对象
-        @param uid: uid
-        @param event_type: 事件类型
-        @return: True 可以使用阿里云, False 配额已满需要降级到AWS
-        """
-        try:
-            # 从 Redis 获取配额限制值,如果不存在则使用默认值
-            quota_limit_key = RedisKeyConstant.ALICLOUD_DAILY_QUOTA_LIMIT.value
-            quota_limit = redis_obj.get_data(key=quota_limit_key)
-            
-            if quota_limit:
-                quota_limit = int(quota_limit)
-            else:
-                # 默认配额限制,如果 Redis 中没有设置则使用这个值
-                quota_limit = ALICLOUD_OSS_DAILY_QUOTA
-            
-            # 获取当前日期作为key的一部分
-            current_date = datetime.datetime.now().strftime('%Y%m%d')
-            quota_key = RedisKeyConstant.ALICLOUD_DAILY_QUOTA_COUNTER.value + current_date
-            
-            # 获取当前计数
-            current_count = redis_obj.get_data(key=quota_key)
-            
-            if current_count is None:
-                # 首次使用,设置计数为1,过期时间为当天结束(86400秒)
-                redis_obj.set_data(key=quota_key, val=1, expire=86400)
-                return True
-            
-            current_count = int(current_count)
-            
-            # 检查是否超过配额
-            if current_count >= quota_limit:
-                LOGGING.info('阿里云存储配额已满,当前:{},限制:{},降级到AWS'.format(
-                    current_count, quota_limit))
-                return False
-            
-            # 增加计数
-            redis_obj.incr(quota_key)
-            LOGGING.info('阿里云存储uid:{}, event_type{}'.format(uid, event_type))
-            return True
-            
-        except Exception as e:
-            ERROR_INFO_LOGGER.info('检查阿里云配额异常,error_line:{},error_msg:{}'.format(
-                e.__traceback__.tb_lineno, repr(e)))
-            # 异常时默认允许使用阿里云
-            return True
-
     @staticmethod
     def create_alicloud_oss_signed_url(key_name):
         """