作者 邓超

x

... ... @@ -3,6 +3,7 @@
namespace Event;
use Model\folderSql;
use Model\listsSql;
use Swlib\Saber;
use Swlib\SaberGM;
... ... @@ -14,63 +15,42 @@ use Swlib\SaberGM;
* @package Event
*/
class syncMail {
/**
* @var \Lib\Db|\Lib\DbPool
*/
private $db;
public function __construct($id,$header,$data)
{
$db = db();
$this->db = db();
// 是否是预热邮件 aicc专用
if(!empty($header['Aicc-Hot-Mail']) || !empty($header['aicc-hot-mail'])){
return $this->hot($id);
}
// 是否在指定文件夹内
$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']);
// 是否在指定文件夹内
$f = $db->value(folderSql::first($data['folder_id'],'folder'));
$f = folderAlias($f);
if($f=='收件箱'){
$f = 's';
}elseif($f=='发件箱'){
$f = 'f';
}elseif($f=='垃圾箱'){
$f = 'l';
}
if(in_array($f,['s','f','l'])){
// 是否是预热邮件 aicc专用
if(!empty($header['Aicc-Hot-Mail']) || !empty($header['aicc-hot-mail'])){
$is_hot = 1;
}
if(empty($is_hot)){
if($f=='f'){
$w = ['email' => array_column($data['to_name'],'email')];
}else{
$w = ['email' =>$data['from']];
}
if($db->count('select count(*) from `hot_mail` where '.dbWhere($w))){
$is_hot = 1;
}
// 是否在 预热邮箱中
if($this->db->count('select count(*) from `hot_mail` where '.dbWhere($w))){
return $this->hot($id);
}
if(!empty($is_hot)){
try {
// 记录日志
logs('识别到aicc预热邮件 '.$id.'-'.$data['email_id'].'-'.$data['from'],LOG_PATH.'/hot-mail.log');
$db->throw()->insert('fob_hot_mail',[
'lists_id' => $id,
'email_id' => $data['email_id'],
'hot_form' => $data['from'],
'folder' => $f
],false);
}catch (\Throwable $exception){
logs($exception->getMessage());
}
}else{
if($f == 's'){
// 不是预热邮箱
if($f=='收件箱'){
// mimecast@wsa.aero
$filterEmail = ['mimecast@wsa.aero'];
// 邮件过滤 这些邮箱都是系统邮箱
... ... @@ -92,13 +72,12 @@ class syncMail {
}
}
}
}
private function hot($id){
return $this->db->update(listsSql::$table,['is_hots'=>1],dbWhere(['id'=>$id]));
}
/**
... ...