作者 邓超

优化ai邮件同步

... ... @@ -65,6 +65,11 @@ function start(){
(new \Lib\Imap\ImapSearch())
->dateGt(date('Y-m-d',strtotime("-1 day")))
);
// 不同步文件夹
if(!redis()->add('ai_sync_email_no_sync_folder:'.$email['id'],1,rand(3600,86400))){
$sync->noSyncFolder();
}
$sync->isUidAfter(2)->sync();
$sync = null;
... ...
... ... @@ -60,7 +60,7 @@ function fob_mysql(){
'admin_hagro_cn',
'admin_hagro_cn',
'rEHsd8xf4xGJKHdD',
63634,
63634
);
// 这个是内网,不知道能不能用
... ...
... ... @@ -147,6 +147,19 @@ class SyncMail {
return $this;
}
protected $isSyncFolder = true;
/**
* 是否同步文件夹
* @return $this
* @author:dc
* @time 2025/9/13 15:34
*/
public function noSyncFolder(){
$this->isSyncFolder = false;
return $this;
}
protected function emailId(){
return $this->email['id'];
... ... @@ -281,10 +294,13 @@ class SyncMail {
/*********************************** 同步文件夹 ***************************************/
// 获取文件夹
$folders = $this->imap->getFolders();
$uuids = $this->folder($folders->getTopFolder());
if($uuids){
// 删除以前的
$this->db->delete(folderSql::$table,['uuid.notin'=>$uuids,'email_id'=>$this->emailId()]);
if($this->isSyncFolder){
$uuids = $this->folder($folders->getTopFolder());
if($uuids){
// 删除以前的
$this->db->delete(folderSql::$table,['uuid.notin'=>$uuids,'email_id'=>$this->emailId()]);
}
}
if (!$syncMail) return true;
... ...