正在显示
1 个修改的文件
包含
9 行增加
和
24 行删除
@@ -100,34 +100,24 @@ class Home extends Base { | @@ -100,34 +100,24 @@ class Home extends Base { | ||
100 | * @time 2023/8/2 16:19 | 100 | * @time 2023/8/2 16:19 |
101 | */ | 101 | */ |
102 | public function sync(){ | 102 | public function sync(){ |
103 | - $emails = web_request_emails(); | ||
104 | - $udate = app()->request('udate'); | ||
105 | - if(!$udate || !is_array($udate)){ | ||
106 | - return ''; | ||
107 | - } | ||
108 | - | ||
109 | - // 查询邮箱 | ||
110 | - $emails = db()->all(emailSql::all(dbWhere(['email'=>$emails]))); | ||
111 | - if(!$emails){ | 103 | + $email = $this->getEmail(); |
104 | + $udate = app()->request('udate',0,'intval'); | ||
105 | + if(!$udate){ | ||
112 | return ''; | 106 | return ''; |
113 | } | 107 | } |
114 | - | ||
115 | - // 启用协程来处理 | ||
116 | - run(function () use ($emails,$udate){ | ||
117 | - foreach ($emails as $email){ | ||
118 | // 读取文件夹 | 108 | // 读取文件夹 |
119 | $fids = $this->getFolderIds($email['id']); | 109 | $fids = $this->getFolderIds($email['id']); |
120 | $folders = db()->all(folderSql::all($email['id'])); | 110 | $folders = db()->all(folderSql::all($email['id'])); |
121 | - // 循环 文件夹 | ||
122 | - foreach ($folders as $folder){ | ||
123 | - // 是否在同步请求中 | ||
124 | - if(in_array($folder['id'],$fids)){ | ||
125 | // 启动 协程 | 111 | // 启动 协程 |
126 | - go(function () use ($email,$udate,$folder){ | ||
127 | // 实例一个邮箱对象 | 112 | // 实例一个邮箱对象 |
128 | $mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']); | 113 | $mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']); |
129 | // 登录 | 114 | // 登录 |
130 | $mail->login(); | 115 | $mail->login(); |
116 | + | ||
117 | + // 循环 文件夹 | ||
118 | + foreach ($folders as $folder){ | ||
119 | + // 是否在同步请求中 | ||
120 | + if(in_array($folder['id'],$fids)){ | ||
131 | // 选择 文件夹 | 121 | // 选择 文件夹 |
132 | $mail->client->selectFolder($folder['origin_folder']); | 122 | $mail->client->selectFolder($folder['origin_folder']); |
133 | // 最后的时间 | 123 | // 最后的时间 |
@@ -139,7 +129,7 @@ class Home extends Base { | @@ -139,7 +129,7 @@ class Home extends Base { | ||
139 | $folder['id'] | 129 | $folder['id'] |
140 | ) | 130 | ) |
141 | ); | 131 | ); |
142 | - $udate = ($udate[$email['email']]??0) > $maxudate ? $udate : $maxudate; | 132 | + $udate = $udate > $maxudate ? $udate : $maxudate; |
143 | 133 | ||
144 | // 通过时间来搜索uid | 134 | // 通过时间来搜索uid |
145 | $uids = $mail->client->search(['ON'=>date('Y-m-d H:i:s',$udate)]); | 135 | $uids = $mail->client->search(['ON'=>date('Y-m-d H:i:s',$udate)]); |
@@ -153,14 +143,9 @@ class Home extends Base { | @@ -153,14 +143,9 @@ class Home extends Base { | ||
153 | [], | 143 | [], |
154 | db() | 144 | db() |
155 | ); | 145 | ); |
156 | - | ||
157 | - }); | ||
158 | } | 146 | } |
159 | } | 147 | } |
160 | 148 | ||
161 | - } | ||
162 | - | ||
163 | - }); | ||
164 | 149 | ||
165 | } | 150 | } |
166 | 151 |
-
请 注册 或 登录 后发表评论