正在显示
1 个修改的文件
包含
44 行增加
和
65 行删除
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | namespace Event; | 3 | namespace Event; |
4 | 4 | ||
5 | use Model\folderSql; | 5 | use Model\folderSql; |
6 | +use Model\listsSql; | ||
6 | use Swlib\Saber; | 7 | use Swlib\Saber; |
7 | use Swlib\SaberGM; | 8 | use Swlib\SaberGM; |
8 | 9 | ||
@@ -14,91 +15,69 @@ use Swlib\SaberGM; | @@ -14,91 +15,69 @@ use Swlib\SaberGM; | ||
14 | * @package Event | 15 | * @package Event |
15 | */ | 16 | */ |
16 | class syncMail { | 17 | class syncMail { |
18 | + /** | ||
19 | + * @var \Lib\Db|\Lib\DbPool | ||
20 | + */ | ||
21 | + private $db; | ||
17 | 22 | ||
18 | 23 | ||
19 | public function __construct($id,$header,$data) | 24 | public function __construct($id,$header,$data) |
20 | { | 25 | { |
21 | - $db = db(); | 26 | + $this->db = db(); |
22 | 27 | ||
23 | - if(empty($data['to_name'])){ | ||
24 | - $data['to_name'] = []; | 28 | + // 是否是预热邮件 aicc专用 |
29 | + if(!empty($header['Aicc-Hot-Mail']) || !empty($header['aicc-hot-mail'])){ | ||
30 | + return $this->hot($id); | ||
25 | } | 31 | } |
26 | 32 | ||
27 | - $data['to_name'] = is_array($data['to_name'])?$data['to_name']:json_decode($data['to_name']); | ||
28 | - | ||
29 | // 是否在指定文件夹内 | 33 | // 是否在指定文件夹内 |
30 | - $f = $db->value(folderSql::first($data['folder_id'],'folder')); | ||
31 | - $f = folderAlias($f); | ||
32 | - if($f=='收件箱'){ | ||
33 | - $f = 's'; | ||
34 | - }elseif($f=='发件箱'){ | ||
35 | - $f = 'f'; | ||
36 | - }elseif($f=='垃圾箱'){ | ||
37 | - $f = 'l'; | ||
38 | - } | ||
39 | - if(in_array($f,['s','f','l'])){ | ||
40 | - // 是否是预热邮件 aicc专用 | ||
41 | - if(!empty($header['Aicc-Hot-Mail']) || !empty($header['aicc-hot-mail'])){ | ||
42 | - $is_hot = 1; | 34 | + $f = folderAlias($this->db->value(folderSql::first($data['folder_id'],'folder'))); |
35 | + if($f=='发件箱'){ | ||
36 | + if(empty($data['to_name'])){ | ||
37 | + $data['to_name'] = []; | ||
43 | } | 38 | } |
44 | 39 | ||
45 | - if(empty($is_hot)){ | ||
46 | - if($f=='f'){ | ||
47 | - $w = ['email' => array_column($data['to_name'],'email')]; | ||
48 | - }else{ | ||
49 | - $w = ['email' =>$data['from']]; | ||
50 | - } | 40 | + $data['to_name'] = is_array($data['to_name'])?$data['to_name']:json_decode($data['to_name']); |
41 | + | ||
42 | + $w = ['email' => array_column($data['to_name'],'email')]; | ||
43 | + }else{ | ||
44 | + $w = ['email' =>$data['from']]; | ||
45 | + } | ||
46 | + // 是否在 预热邮箱中 | ||
47 | + if($this->db->count('select count(*) from `hot_mail` where '.dbWhere($w))){ | ||
48 | + return $this->hot($id); | ||
49 | + } | ||
51 | 50 | ||
52 | - if($db->count('select count(*) from `hot_mail` where '.dbWhere($w))){ | ||
53 | - $is_hot = 1; | ||
54 | - } | ||
55 | - } | ||
56 | 51 | ||
57 | - if(!empty($is_hot)){ | 52 | + // 不是预热邮箱 |
53 | + if($f=='收件箱'){ | ||
54 | + // mimecast@wsa.aero | ||
55 | + $filterEmail = ['mimecast@wsa.aero']; | ||
56 | + // 邮件过滤 这些邮箱都是系统邮箱 | ||
57 | + if(!in_array($data['from'],$filterEmail) && !preg_match("/^((no-?reply)|(postmaster)|(mailer-daemon)|(email-notifications)|(googleplay-noreply)|(postmaster-noreply)|(privacy-noreply))@/i",$data['from']) && !$this->checkSubject($data['subject'])){ | ||
58 | + // 通知黑格 2024-08-22 新上 这个是异步的不会阻塞当前进程 | ||
58 | try { | 59 | try { |
59 | - // 记录日志 | ||
60 | - logs('识别到aicc预热邮件 '.$id.'-'.$data['email_id'].'-'.$data['from'],LOG_PATH.'/hot-mail.log'); | ||
61 | - | ||
62 | - $db->throw()->insert('fob_hot_mail',[ | ||
63 | - 'lists_id' => $id, | ||
64 | - 'email_id' => $data['email_id'], | ||
65 | - 'hot_form' => $data['from'], | ||
66 | - 'folder' => $f | ||
67 | - ],false); | ||
68 | - | ||
69 | - }catch (\Throwable $exception){ | ||
70 | - logs($exception->getMessage()); | 60 | + SaberGM::post('https://fob.ai.cc/api/email_new_push',[ |
61 | + 'sign' => md5(date('ymd').'fob.ai.cc.email'), | ||
62 | + 'id' => $id, | ||
63 | + 'subject' => $data['subject'], | ||
64 | + 'udate' => $data['udate'], | ||
65 | + 'from' => $data['from'], | ||
66 | + 'tos' => array_column(json_decode($data['to_name'],1),'email') | ||
67 | + ]); | ||
68 | + }catch (\Throwable $e){ | ||
69 | + // 就算异常了也不在推送了 | ||
71 | } | 70 | } |
72 | - }else{ | ||
73 | - if($f == 's'){ | ||
74 | - // mimecast@wsa.aero | ||
75 | - $filterEmail = ['mimecast@wsa.aero']; | ||
76 | - // 邮件过滤 这些邮箱都是系统邮箱 | ||
77 | - if(!in_array($data['from'],$filterEmail) && !preg_match("/^((no-?reply)|(postmaster)|(mailer-daemon)|(email-notifications)|(googleplay-noreply)|(postmaster-noreply)|(privacy-noreply))@/i",$data['from']) && !$this->checkSubject($data['subject'])){ | ||
78 | - // 通知黑格 2024-08-22 新上 这个是异步的不会阻塞当前进程 | ||
79 | - try { | ||
80 | - SaberGM::post('https://fob.ai.cc/api/email_new_push',[ | ||
81 | - 'sign' => md5(date('ymd').'fob.ai.cc.email'), | ||
82 | - 'id' => $id, | ||
83 | - 'subject' => $data['subject'], | ||
84 | - 'udate' => $data['udate'], | ||
85 | - 'from' => $data['from'], | ||
86 | - 'tos' => array_column(json_decode($data['to_name'],1),'email') | ||
87 | - ]); | ||
88 | - }catch (\Throwable $e){ | ||
89 | - // 就算异常了也不在推送了 | ||
90 | - } | ||
91 | - | ||
92 | - } | ||
93 | - | ||
94 | 71 | ||
95 | - | ||
96 | - } | ||
97 | } | 72 | } |
98 | 73 | ||
74 | + | ||
99 | } | 75 | } |
100 | 76 | ||
77 | + } | ||
101 | 78 | ||
79 | + private function hot($id){ | ||
80 | + return $this->db->update(listsSql::$table,['is_hots'=>1],dbWhere(['id'=>$id])); | ||
102 | } | 81 | } |
103 | 82 | ||
104 | /** | 83 | /** |
-
请 注册 或 登录 后发表评论