...
|
...
|
@@ -275,6 +275,32 @@ class SyncMail { |
|
|
],'`id`'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 过滤uid
|
|
|
* @param array $uids
|
|
|
* @return array
|
|
|
* @author:dc
|
|
|
* @time 2024/11/12 14:17
|
|
|
*/
|
|
|
private function getFilterUid(array $uids, int $folder_id):array {
|
|
|
foreach ($uids as $k=>$uid){
|
|
|
|
|
|
$num = redis()->get('h_'.$folder_id.'_'.$uid,function () use ($folder_id,$uid){
|
|
|
$num = $this->db->value(listsSql::first(dbWhere(['email_id'=>$this->emailId(),'folder_id'=>$folder_id,'uid'=>$uid]),'count(*) as c'));
|
|
|
if($num){
|
|
|
redis()->set('h_'.$folder_id.'_'.$uid,1,86400);
|
|
|
}
|
|
|
return $num;
|
|
|
});
|
|
|
|
|
|
if($num){
|
|
|
unset($uids[$k]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return array_values($uids);
|
|
|
}
|
|
|
|
|
|
/**同步邮件
|
|
|
*
|
|
|
* @param string|\Lib\Imap\Request\Folder $folder
|
...
|
...
|
@@ -308,26 +334,10 @@ class SyncMail { |
|
|
$uids = $msg->forPage($p)->getOriginUids();
|
|
|
}
|
|
|
|
|
|
$uids = $this->getFilterUid($uids,$folder_id);
|
|
|
|
|
|
if($uids){
|
|
|
$p++;
|
|
|
|
|
|
foreach ($uids as $k=>$uid){
|
|
|
|
|
|
$num = redis()->get('h_'.$folder_id.'_'.$uid,function () use ($folder_id,$uid){
|
|
|
$num = $this->db->value(listsSql::first(dbWhere(['email_id'=>$this->emailId(),'folder_id'=>$folder_id,'uid'=>$uid]),'count(*) as c'));
|
|
|
if($num){
|
|
|
redis()->set('h_'.$folder_id.'_'.$uid,1,86400);
|
|
|
}
|
|
|
return $num;
|
|
|
});
|
|
|
|
|
|
if($num){
|
|
|
unset($uids[$k]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(!$uids) continue;
|
|
|
|
|
|
$lists = $msg->uid($uids)->get()->all();
|
|
|
$sync_number += count($lists);
|
|
|
// 没有数据就跳出
|
...
|
...
|
@@ -337,7 +347,7 @@ class SyncMail { |
|
|
}else{
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 只需要执行一次
|
|
|
if ($this->search instanceof ImapSearch){
|
|
|
break;
|
|
|
}
|
...
|
...
|
|