作者 邓超

job

... ... @@ -55,6 +55,12 @@ class SyncMail {
*/
protected $isForceUpdate = false;
/**
* 是否输出日志
* @var bool
*/
protected $echoLog = false;
/**
* SyncMail constructor.
... ... @@ -94,6 +100,27 @@ class SyncMail {
}
/**
* @param bool $echoLog
*/
public function setEchoLog()
{
$this->echoLog = true;
return $this;
}
/**
* 输出日志
* @param $msg
* @author:dc
* @time 2025/3/20 11:03
*/
protected function eLog($msg){
if($this->echoLog){
_echo($msg);
}
}
/**
* 搜索
* @param ImapSearch $search
* @return $this
... ... @@ -335,7 +362,7 @@ class SyncMail {
if(is_string($folder)){
$folder = $this->imap->folder($folder)->exec();
}
$this->eLog("正在同步 ".$folder->getName());
$folder_id = $this->getFolderId($folder->getName());
if($folder->getName() == 'INBOX'){
$this->folder_inbox_id = $folder_id;
... ... @@ -461,12 +488,19 @@ class SyncMail {
]),'`id`'));
if(!$id){
$id = $this->insert($data);
// 收件箱直接 未读 不远程为准
$this->eLog(
sprintf("正在插入数据 eid:%d fid:%d uid:%d subject: %s",
$data['email_id'],
$data['folder_id'],
$data['uid'],
$data['subject'],
));
// 收件箱直接 未读 不远程为准
if(defined('CLI_AI_SYNC_START') && !empty($this->folder_inbox_id) && $this->folder_inbox_id == $data['folder_id']){
$data['seen'] = 0;
}
$id = $this->insert($data);
if(!$id){
continue;
... ... @@ -482,6 +516,13 @@ class SyncMail {
}else{
// 非ai邮件才更新
if(!defined('CLI_AI_SYNC_START')){
$this->eLog(
sprintf("正在update数据 eid:%d fid:%d uid:%d subject: %s",
$data['email_id'],
$data['folder_id'],
$data['uid'],
$data['subject'],
));
$this->db->update(listsSql::$table,$data,dbWhere(['id'=> $id]));
}
... ...