作者 邓超

优化预热

@@ -28,10 +28,13 @@ class SyncMail { @@ -28,10 +28,13 @@ class SyncMail {
28 // if(php_sapi_name() == 'cli'){ 28 // if(php_sapi_name() == 'cli'){
29 $this->db = db(); 29 $this->db = db();
30 30
31 - // 是否是预热邮件 aicc专用  
32 - if(!empty($header['Aicc-Hot-Mail']) || !empty($header['aicc-hot-mail'])){  
33 - return $this->hot($id); 31 + if($data['is_hots']){
  32 + return true;
34 } 33 }
  34 + // 是否是预热邮件 aicc专用
  35 +// if(!empty($header['Aicc-Hot-Mail']) || !empty($header['aicc-hot-mail'])){
  36 +// return $this->hot($id);
  37 +// }
35 38
36 // 是否在指定文件夹内 39 // 是否在指定文件夹内
37 $f = $this->db->value(folderSql::first($data['folder_id'],'folder')); 40 $f = $this->db->value(folderSql::first($data['folder_id'],'folder'));
@@ -39,21 +42,21 @@ class SyncMail { @@ -39,21 +42,21 @@ class SyncMail {
39 return true; 42 return true;
40 } 43 }
41 $f = folderAlias($f); 44 $f = folderAlias($f);
42 - if($f=='发件箱'){  
43 - if(empty($data['to_name'])){  
44 - $data['to_name'] = [];  
45 - }  
46 -  
47 - $data['to_name'] = is_array($data['to_name'])?$data['to_name']:json_decode($data['to_name']);  
48 -  
49 - $w = ['email' => array_map('strtolower',array_column($data['to_name'],'email'))];  
50 - }else{  
51 - $w = ['email' => strtolower($data['from'])];  
52 - }  
53 - // 是否在 预热邮箱中  
54 - if($w['email'] && $this->db->count('select count(*) from `hot_mail` where '.dbWhere($w))){  
55 - return $this->hot($id);  
56 - } 45 +// if($f=='发件箱'){
  46 +// if(empty($data['to_name'])){
  47 +// $data['to_name'] = [];
  48 +// }
  49 +//
  50 +// $data['to_name'] = is_array($data['to_name'])?$data['to_name']:json_decode($data['to_name']);
  51 +//
  52 +// $w = ['email' => array_map('strtolower',array_column($data['to_name'],'email'))];
  53 +// }else{
  54 +// $w = ['email' => strtolower($data['from'])];
  55 +// }
  56 +// // 是否在 预热邮箱中
  57 +// if($w['email'] && $this->db->count('select count(*) from `hot_mail` where '.dbWhere($w))){
  58 +// return $this->hot($id);
  59 +// }
57 60
58 61
59 // 不是预热邮箱 62 // 不是预热邮箱
@@ -92,9 +95,9 @@ class SyncMail { @@ -92,9 +95,9 @@ class SyncMail {
92 95
93 } 96 }
94 97
95 - private function hot($id){  
96 - return $this->db->update(listsSql::$table,['is_hots'=>1],dbWhere(['id'=>$id]));  
97 - } 98 +// private function hot($id){
  99 +// return $this->db->update(listsSql::$table,['is_hots'=>1],dbWhere(['id'=>$id]));
  100 +// }
98 101
99 102
100 /** 103 /**
@@ -476,8 +476,10 @@ class SyncMail { @@ -476,8 +476,10 @@ class SyncMail {
476 'folder_id' => $folder_id, 476 'folder_id' => $folder_id,
477 'email_id' => $this->emailId(), 477 'email_id' => $this->emailId(),
478 'is_file' => $item->isAttachment() ? 1: 0, //是否附件 478 'is_file' => $item->isAttachment() ? 1: 0, //是否附件
479 - 'is_hots' => $item->header->get('Aicc-Hot-Mail')?1:0 // 是否是预热  
480 ]; 479 ];
  480 +
  481 + $data['is_hots'] = $this->isHot($item->header->get('Aicc-Hot-Mail'),$data) ? 1 : 0; // 是否是预热
  482 +
481 }catch (\Throwable $e){ 483 }catch (\Throwable $e){
482 logs([$e->getMessage(),$folder_id,$this->emailId(),$item->uid]); 484 logs([$e->getMessage(),$folder_id,$this->emailId(),$item->uid]);
483 continue; 485 continue;
@@ -631,6 +633,38 @@ class SyncMail { @@ -631,6 +633,38 @@ class SyncMail {
631 } 633 }
632 634
633 /** 635 /**
  636 + * 是否是预热邮件
  637 + * @param $header
  638 + * @param $data
  639 + * @return bool
  640 + * @author:dc
  641 + * @time 2025/5/23 18:11
  642 + */
  643 + private function isHot($header,$data){
  644 + // 是否是预热邮件 aicc专用
  645 + if($header){ return true; }
  646 +
  647 + // 是否在指定文件夹内
  648 + $f = folderAlias($this->db->value(folderSql::first($data['folder_id'],'folder')));
  649 + if($f == '发件箱'){
  650 + if(empty($data['to_name'])){
  651 + $data['to_name'] = [];
  652 + }
  653 +
  654 + $data['to_name'] = is_array($data['to_name'])?$data['to_name']:json_decode($data['to_name']);
  655 +
  656 + $w = ['email' => array_map('strtolower',array_column($data['to_name'],'email'))];
  657 + }else{
  658 + $w = ['email' => strtolower($data['from'])];
  659 + }
  660 + // 是否在 预热邮箱中
  661 + if($w['email'] && $this->db->count('select count(*) from `hot_mail` where '.dbWhere($w))){
  662 + return true;
  663 + }
  664 + return false;
  665 + }
  666 +
  667 + /**
634 * 查询数据 并重试 668 * 查询数据 并重试
635 * @param array $data 669 * @param array $data
636 * @param int $num 670 * @param int $num