作者 邓超

优化同步

... ... @@ -25,16 +25,13 @@ class SyncMail {
public function __construct(int $id, array $data)
{
// if(php_sapi_name() == 'cli'){
$this->db = db();
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'));
... ... @@ -42,21 +39,6 @@ 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);
// }
// 不是预热邮箱
... ... @@ -64,7 +46,6 @@ class SyncMail {
$this->auto_mail($id,$data);
$this->black_mail($id,$data);
// 邮件过滤 这些邮箱都是系统邮箱
// if(!$this->checkEmail($data['from']) && !$this->checkSubject($data['subject'])){
... ... @@ -89,15 +70,9 @@ class SyncMail {
}
// }
}
// private function hot($id){
// return $this->db->update(listsSql::$table,['is_hots'=>1],dbWhere(['id'=>$id]));
// }
/**
... ... @@ -173,31 +148,6 @@ class SyncMail {
}
/**
* 黑名单邮箱,直接delete
* @param $id
* @param $data
* @author:dc
* @time 2024/9/12 15:29
*/
private function black_mail($id,$data){
if(!empty($data['from'])){
// 是否是ai邮件
if($this->db->count("select count(*) from `hot_mail` where ".dbWhere([
'email'=> $this->db->value(emailSql::first($data['email_id'],'`email`'))
]))){
// 是否在黑名单中
if($this->db->count("select count(*) from `ai_black_email` where ".dbWhere(['email'=>$data['from']]))){
$this->db->update(listsSql::$table,['deleted'=>1],dbWhere(['id'=>$id]));
}
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -477,6 +477,8 @@ class SyncMail {
'email_id' => $this->emailId(),
'is_file' => $item->isAttachment() ? 1: 0, //是否附件
];
// 是否是黑名单,黑名单要删除
$data['deleted'] = $this->black_mail($data);
$data['is_hots'] = $this->isHot($item->header->get('Aicc-Hot-Mail'),$data) ? 1 : 0; // 是否是预热
... ... @@ -516,10 +518,10 @@ class SyncMail {
$data['seen'] = 0;
}
$id = $this->insert($data);
if(!$id){
continue;
}
// 新邮件标记
if($item->getFolderName() == 'INBOX')
redis()->incr('have_new_mail_'.$this->emailId(),120);
... ... @@ -665,6 +667,31 @@ class SyncMail {
}
/**
* 黑名单邮箱,直接delete
* @param $data
* @author:dc
* @time 2024/9/12 15:29
*/
private function black_mail($data){
if(!empty($data['from'])){
// 是否是ai邮件
if($this->db->count("select count(*) from `hot_mail` where ".dbWhere([
'email'=> $this->db->value(emailSql::first($data['email_id'],'`email`'))
]))){
// 是否在黑名单中
if($this->db->count("select count(*) from `ai_black_email` where ".dbWhere(['email'=>$data['from']]))){
return 1;
}
}
}
return 0;
}
/**
* 查询数据 并重试
* @param array $data
* @param int $num
... ...