mirror of
https://github.com/yeongpin/cursor-free-vip.git
synced 2025-08-02 20:47:35 +08:00
优化邮件检查功能,简化逻辑,直接检查邮件列表中的第一个邮件是否为新邮件,并更新相关文档注释。
This commit is contained in:
parent
fa74b17dce
commit
e190a81ee4
@ -40,10 +40,10 @@ class TempMailPlusTab(EmailTabInterface):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def check_for_cursor_email(self) -> bool:
|
def check_for_cursor_email(self) -> bool:
|
||||||
"""Check if there is a new email within the last 3 minutes
|
"""Check if there is a new email
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if new email within 3 minutes exists, False otherwise
|
bool: True if the first email in mail_list is new, False otherwise
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
params = {
|
params = {
|
||||||
@ -60,18 +60,10 @@ class TempMailPlusTab(EmailTabInterface):
|
|||||||
|
|
||||||
data = response.json()
|
data = response.json()
|
||||||
if data.get('result') and data.get('mail_list'):
|
if data.get('result') and data.get('mail_list'):
|
||||||
current_time = datetime.datetime.now()
|
# 检查邮件列表中的第一个邮件是否为新邮件
|
||||||
for mail in data['mail_list']:
|
if data['mail_list'][0].get('is_new') == True:
|
||||||
if mail.get('is_new') == True:
|
self._cached_mail_id = data['mail_list'][0].get('mail_id') # 缓存mail_id
|
||||||
# 检查邮件时间是否在3分钟内
|
return True
|
||||||
try:
|
|
||||||
mail_time = datetime.datetime.strptime(mail.get('time', ''), '%Y-%m-%d %H:%M:%S')
|
|
||||||
time_diff = (current_time - mail_time).total_seconds() / 60 # 转换为分钟
|
|
||||||
if time_diff <= 3: # 3分钟内的邮件
|
|
||||||
self._cached_mail_id = mail.get('mail_id') # 缓存mail_id
|
|
||||||
return True
|
|
||||||
except ValueError:
|
|
||||||
continue
|
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"检查新邮件失败: {str(e)}")
|
print(f"检查新邮件失败: {str(e)}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user