@@ -669,8 +669,8 @@ def is_valid(self, *, raise_exception=False):
669669 raise ExceptionCodeConstants .EMAIL_IS_EXIST .value .to_app_api_exception ()
670670 code_cache_key = self .data .get ('email' ) + ":" + self .data .get ("type" )
671671 code_cache_key_lock = code_cache_key + "_lock"
672- ttl = cache .ttl (code_cache_key_lock )
673- if ttl is not None :
672+ ttl = cache .ttl (code_cache_key_lock , version = version )
673+ if ttl is not None and ttl > 0 :
674674 raise AppApiException (500 , _ ("Do not send emails again within {seconds} seconds" ).format (
675675 seconds = int (ttl .total_seconds ())))
676676 return True
@@ -696,7 +696,7 @@ def send(self):
696696 code_cache_key = email + ":" + state
697697 code_cache_key_lock = code_cache_key + "_lock"
698698 # 设置缓存
699- cache .set (get_key (code_cache_key_lock ), code , timeout = datetime . timedelta ( minutes = 1 ) , version = version )
699+ cache .set (get_key (code_cache_key_lock ), code , timeout = 60 , version = version )
700700 system_setting = QuerySet (SystemSetting ).filter (type = SettingType .EMAIL .value ).first ()
701701 if system_setting is None :
702702 cache .delete (get_key (code_cache_key_lock ), version = version )
@@ -721,7 +721,7 @@ def send(self):
721721 except Exception as e :
722722 cache .delete (get_key (code_cache_key_lock ))
723723 raise AppApiException (500 , f"{ str (e )} " + _ ("Email sending failed" ))
724- cache .set (get_key (code_cache_key ), code , timeout = datetime . timedelta ( minutes = 30 ) , version = version )
724+ cache .set (get_key (code_cache_key ), code , timeout = 60 * 30 , version = version )
725725 return True
726726
727727
0 commit comments