perf: 优化频繁发送短信,将后端的频繁发送警告提示到页面上来提醒用户

This commit is contained in:
jiangweidong
2024-04-19 17:11:25 +08:00
committed by Bryan
parent ad0bc82539
commit ef7329a721
3 changed files with 15 additions and 6 deletions

View File

@@ -30,14 +30,14 @@ class SendAndVerifyCodeUtil(object):
self.other_args = kwargs
def gen_and_send_async(self):
ttl = self.__ttl()
if ttl > 0:
logger.warning('Send sms too frequently, delay {}'.format(ttl))
raise CodeSendTooFrequently(ttl)
return send_async.apply_async(kwargs={"sender": self}, priority=100)
def gen_and_send(self):
ttl = self.__ttl()
if ttl > 0:
logger.error('Send sms too frequently, delay {}'.format(ttl))
raise CodeSendTooFrequently(ttl)
try:
if not self.code:
self.code = self.__generate()