...
|
...
|
@@ -100,34 +100,24 @@ class Home extends Base { |
|
|
* @time 2023/8/2 16:19
|
|
|
*/
|
|
|
public function sync(){
|
|
|
$emails = web_request_emails();
|
|
|
$udate = app()->request('udate');
|
|
|
if(!$udate || !is_array($udate)){
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
// 查询邮箱
|
|
|
$emails = db()->all(emailSql::all(dbWhere(['email'=>$emails])));
|
|
|
if(!$emails){
|
|
|
$email = $this->getEmail();
|
|
|
$udate = app()->request('udate',0,'intval');
|
|
|
if(!$udate){
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
// 启用协程来处理
|
|
|
run(function () use ($emails,$udate){
|
|
|
foreach ($emails as $email){
|
|
|
// 读取文件夹
|
|
|
$fids = $this->getFolderIds($email['id']);
|
|
|
$folders = db()->all(folderSql::all($email['id']));
|
|
|
// 循环 文件夹
|
|
|
foreach ($folders as $folder){
|
|
|
// 是否在同步请求中
|
|
|
if(in_array($folder['id'],$fids)){
|
|
|
// 启动 协程
|
|
|
go(function () use ($email,$udate,$folder){
|
|
|
// 实例一个邮箱对象
|
|
|
$mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']);
|
|
|
// 登录
|
|
|
$mail->login();
|
|
|
|
|
|
// 循环 文件夹
|
|
|
foreach ($folders as $folder){
|
|
|
// 是否在同步请求中
|
|
|
if(in_array($folder['id'],$fids)){
|
|
|
// 选择 文件夹
|
|
|
$mail->client->selectFolder($folder['origin_folder']);
|
|
|
// 最后的时间
|
...
|
...
|
@@ -139,7 +129,7 @@ class Home extends Base { |
|
|
$folder['id']
|
|
|
)
|
|
|
);
|
|
|
$udate = ($udate[$email['email']]??0) > $maxudate ? $udate : $maxudate;
|
|
|
$udate = $udate > $maxudate ? $udate : $maxudate;
|
|
|
|
|
|
// 通过时间来搜索uid
|
|
|
$uids = $mail->client->search(['ON'=>date('Y-m-d H:i:s',$udate)]);
|
...
|
...
|
@@ -153,14 +143,9 @@ class Home extends Base { |
|
|
[],
|
|
|
db()
|
|
|
);
|
|
|
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
|