作者 邓超

优化预热

... ... @@ -28,10 +28,13 @@ class SyncMail {
// if(php_sapi_name() == 'cli'){
$this->db = db();
// 是否是预热邮件 aicc专用
if(!empty($header['Aicc-Hot-Mail']) || !empty($header['aicc-hot-mail'])){
return $this->hot($id);
if($data['is_hots']){
return true;
}
// 是否是预热邮件 aicc专用
// if(!empty($header['Aicc-Hot-Mail']) || !empty($header['aicc-hot-mail'])){
// return $this->hot($id);
// }
// 是否在指定文件夹内
$f = $this->db->value(folderSql::first($data['folder_id'],'folder'));
... ... @@ -39,21 +42,21 @@ class SyncMail {
return true;
}
$f = folderAlias($f);
if($f=='发件箱'){
if(empty($data['to_name'])){
$data['to_name'] = [];
}
$data['to_name'] = is_array($data['to_name'])?$data['to_name']:json_decode($data['to_name']);
$w = ['email' => array_map('strtolower',array_column($data['to_name'],'email'))];
}else{
$w = ['email' => strtolower($data['from'])];
}
// 是否在 预热邮箱中
if($w['email'] && $this->db->count('select count(*) from `hot_mail` where '.dbWhere($w))){
return $this->hot($id);
}
// if($f=='发件箱'){
// if(empty($data['to_name'])){
// $data['to_name'] = [];
// }
//
// $data['to_name'] = is_array($data['to_name'])?$data['to_name']:json_decode($data['to_name']);
//
// $w = ['email' => array_map('strtolower',array_column($data['to_name'],'email'))];
// }else{
// $w = ['email' => strtolower($data['from'])];
// }
// // 是否在 预热邮箱中
// if($w['email'] && $this->db->count('select count(*) from `hot_mail` where '.dbWhere($w))){
// return $this->hot($id);
// }
// 不是预热邮箱
... ... @@ -92,9 +95,9 @@ class SyncMail {
}
private function hot($id){
return $this->db->update(listsSql::$table,['is_hots'=>1],dbWhere(['id'=>$id]));
}
// private function hot($id){
// return $this->db->update(listsSql::$table,['is_hots'=>1],dbWhere(['id'=>$id]));
// }
/**
... ...
... ... @@ -476,8 +476,10 @@ class SyncMail {
'folder_id' => $folder_id,
'email_id' => $this->emailId(),
'is_file' => $item->isAttachment() ? 1: 0, //是否附件
'is_hots' => $item->header->get('Aicc-Hot-Mail')?1:0 // 是否是预热
];
$data['is_hots'] = $this->isHot($item->header->get('Aicc-Hot-Mail'),$data) ? 1 : 0; // 是否是预热
}catch (\Throwable $e){
logs([$e->getMessage(),$folder_id,$this->emailId(),$item->uid]);
continue;
... ... @@ -631,6 +633,38 @@ class SyncMail {
}
/**
* 是否是预热邮件
* @param $header
* @param $data
* @return bool
* @author:dc
* @time 2025/5/23 18:11
*/
private function isHot($header,$data){
// 是否是预热邮件 aicc专用
if($header){ return true; }
// 是否在指定文件夹内
$f = folderAlias($this->db->value(folderSql::first($data['folder_id'],'folder')));
if($f == '发件箱'){
if(empty($data['to_name'])){
$data['to_name'] = [];
}
$data['to_name'] = is_array($data['to_name'])?$data['to_name']:json_decode($data['to_name']);
$w = ['email' => array_map('strtolower',array_column($data['to_name'],'email'))];
}else{
$w = ['email' => strtolower($data['from'])];
}
// 是否在 预热邮箱中
if($w['email'] && $this->db->count('select count(*) from `hot_mail` where '.dbWhere($w))){
return true;
}
return false;
}
/**
* 查询数据 并重试
* @param array $data
* @param int $num
... ...