正在显示
6 个修改的文件
包含
41 行增加
和
18 行删除
@@ -154,8 +154,8 @@ class SyncToEsCmd { | @@ -154,8 +154,8 @@ class SyncToEsCmd { | ||
154 | * @time 2025/5/29 11:47 | 154 | * @time 2025/5/29 11:47 |
155 | */ | 155 | */ |
156 | public function getPostid($email_id){ | 156 | public function getPostid($email_id){ |
157 | - $data = redis()->getSet('fob_bind_mail:'.$email_id,300,function ($email_id){ | ||
158 | - return $this->fob_db->throw()->first("select `post_id`,`source` from `e_mail_binds` where `email_id` = '{$email_id}' and `deleted_at` is null order by `id` desc limit 1"); | 157 | + $data = redis()->getSet('fob_bind_mailx:'.$email_id,300,function ($email_id){ |
158 | + return $this->fob_db->throw()->first("select `post_id`,`source` from `e_mail_binds` where `email_id` = '{$email_id}' order by `id` desc limit 1"); | ||
159 | },$email_id); | 159 | },$email_id); |
160 | 160 | ||
161 | return [ | 161 | return [ |
@@ -834,6 +834,7 @@ class Home extends Base { | @@ -834,6 +834,7 @@ class Home extends Base { | ||
834 | 834 | ||
835 | // 全部标记 | 835 | // 全部标记 |
836 | if(!$mail_ids){ | 836 | if(!$mail_ids){ |
837 | + app()->e('标记失败'); | ||
837 | $folder = app()->request('folder','收件箱','folderAlias'); | 838 | $folder = app()->request('folder','收件箱','folderAlias'); |
838 | // 查询 当前的 文件夹 如果有选中文件夹 就 查询出 选中文件夹的id | 839 | // 查询 当前的 文件夹 如果有选中文件夹 就 查询出 选中文件夹的id |
839 | $fids = db()->all(folderSql::all(array_column($emails,'id'),'`id`,`folder`')); | 840 | $fids = db()->all(folderSql::all(array_column($emails,'id'),'`id`,`folder`')); |
@@ -995,14 +996,17 @@ class Home extends Base { | @@ -995,14 +996,17 @@ class Home extends Base { | ||
995 | $data['allowreply'] = db()->value(folderSql::first(['id'=>$data['folder_id']],'folder'))!='发件箱'?1:0; | 996 | $data['allowreply'] = db()->value(folderSql::first(['id'=>$data['folder_id']],'folder'))!='发件箱'?1:0; |
996 | 997 | ||
997 | $body = db()->first(bodySql::first($id)); | 998 | $body = db()->first(bodySql::first($id)); |
998 | - if(!$body){ | 999 | + if(empty($body['text_html'])){ |
999 | $body = db()->first("select * from `bodies_back` where `lists_id` = ".$id." limit 1"); | 1000 | $body = db()->first("select * from `bodies_back` where `lists_id` = ".$id." limit 1"); |
1000 | - // if(!$body){ | ||
1001 | - // $body = @file_get_contents('http://172.19.0.5:9527?id='.$id); | ||
1002 | - // if($body){ | ||
1003 | - // $body = ['lists_id'=>$id,'text_html'=>$body]; | ||
1004 | - // } | ||
1005 | - // } | 1001 | + if(empty($body['text_html'])){ |
1002 | + $body = @file_get_contents('http://172.19.0.5:9527?id='.$id); | ||
1003 | + if($body){ | ||
1004 | + $body = ['lists_id'=>$id,'text_html'=>$body]; | ||
1005 | + } | ||
1006 | + } | ||
1007 | + } | ||
1008 | + if(empty($body['text_html'])){ | ||
1009 | + $body = []; | ||
1006 | } | 1010 | } |
1007 | if($body && !$reload){ | 1011 | if($body && !$reload){ |
1008 | $data['body'] = json_decode($body['text_html'],true); | 1012 | $data['body'] = json_decode($body['text_html'],true); |
@@ -234,6 +234,17 @@ class MailListV2Es extends Base { | @@ -234,6 +234,17 @@ class MailListV2Es extends Base { | ||
234 | $notinquery[] = ['match_phrase'=>['from.email'=>$sub]]; | 234 | $notinquery[] = ['match_phrase'=>['from.email'=>$sub]]; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | + | ||
238 | + // $no_subject = app()->request('subject'); | ||
239 | + // if ($no_subject) { | ||
240 | + // $no_subject = is_array($no_subject) ? $no_subject : [$no_subject]; | ||
241 | + // foreach ($no_subject as $k => $sub) { | ||
242 | + // if($sub){ | ||
243 | + // $notinquery[] = ['match_phrase'=>['subject'=>$sub]]; | ||
244 | + // } | ||
245 | + // } | ||
246 | + // } | ||
247 | + | ||
237 | if($notinquery){ | 248 | if($notinquery){ |
238 | $query['bool']['must_not'] = $notinquery; | 249 | $query['bool']['must_not'] = $notinquery; |
239 | } | 250 | } |
@@ -242,7 +253,7 @@ class MailListV2Es extends Base { | @@ -242,7 +253,7 @@ class MailListV2Es extends Base { | ||
242 | 253 | ||
243 | 254 | ||
244 | // $result = $this->es->search(['query'=>$query],($page-1) * $limit,$limit,['udate'=>"desc"]); | 255 | // $result = $this->es->search(['query'=>$query],($page-1) * $limit,$limit,['udate'=>"desc"]); |
245 | - $result = $this->es->search(['query'=>['constant_score'=>['filter'=>$query]]],($page-1) * $limit,$limit,['udate'=>"desc"],($where['is_hots']==1||$folder=='垃圾箱')?10000:true); | 256 | + $result = $this->es->search(['query'=>['constant_score'=>['filter'=>$query]]],($page-1) * $limit,$limit,['udate'=>"desc"],(($where['is_hots']??0)==1||$folder=='垃圾箱')?10000:true); |
246 | 257 | ||
247 | 258 | ||
248 | $total = $result['hits']['total']['value']??0; | 259 | $total = $result['hits']['total']['value']??0; |
@@ -282,7 +293,7 @@ class MailListV2Es extends Base { | @@ -282,7 +293,7 @@ class MailListV2Es extends Base { | ||
282 | } | 293 | } |
283 | 294 | ||
284 | // 手动触发同步es | 295 | // 手动触发同步es |
285 | - redis()->rPush('sync_to_es',$v['id']); | 296 | + if(empty($v['is_auto']) && $v['folder_name']=='收件箱') redis()->rPush('sync_to_es',$v['id']); |
286 | 297 | ||
287 | return $v; | 298 | return $v; |
288 | },$lists?:[]); | 299 | },$lists?:[]); |
@@ -180,7 +180,7 @@ class MailListV2Es2 extends Base { | @@ -180,7 +180,7 @@ class MailListV2Es2 extends Base { | ||
180 | // 软删 | 180 | // 软删 |
181 | $where['deleted'] = 0; | 181 | $where['deleted'] = 0; |
182 | $where['source'] = 2; // ai邮件群体 | 182 | $where['source'] = 2; // ai邮件群体 |
183 | -// $where['email_id'] = $this->getEmails('id'); | 183 | + if(count($this->getEmails('id')) == 1) $where['email_id'] = $this->getEmails('id'); |
184 | 184 | ||
185 | $query = [ | 185 | $query = [ |
186 | 'bool'=>[ | 186 | 'bool'=>[ |
@@ -235,7 +235,7 @@ class MailListV2Es2 extends Base { | @@ -235,7 +235,7 @@ class MailListV2Es2 extends Base { | ||
235 | } | 235 | } |
236 | } | 236 | } |
237 | 237 | ||
238 | -// logs(json_encode(['query'=>['constant_score'=>['filter'=>$query]]])); | 238 | + logs('lists '.json_encode(['query'=>['constant_score'=>['filter'=>$query]]])); |
239 | $result = $this->es->search(['query'=>['constant_score'=>['filter'=>$query]]],($page-1) * $limit,$limit,['udate'=>"desc"]); | 239 | $result = $this->es->search(['query'=>['constant_score'=>['filter'=>$query]]],($page-1) * $limit,$limit,['udate'=>"desc"]); |
240 | 240 | ||
241 | 241 | ||
@@ -357,6 +357,7 @@ class MailListV2Es2 extends Base { | @@ -357,6 +357,7 @@ class MailListV2Es2 extends Base { | ||
357 | ] | 357 | ] |
358 | ] | 358 | ] |
359 | ]; | 359 | ]; |
360 | + if(count($this->getEmails('id')) == 1) $body['query']['bool']['must'][] = ['terms'=>['email_id'=>$this->getEmails('id')]]; | ||
360 | // 时间 必须是数组 | 361 | // 时间 必须是数组 |
361 | $udate = app()->request('udate'); | 362 | $udate = app()->request('udate'); |
362 | if($udate && is_array($udate) && count($udate) == 2){ | 363 | if($udate && is_array($udate) && count($udate) == 2){ |
@@ -440,7 +441,9 @@ class MailListV2Es2 extends Base { | @@ -440,7 +441,9 @@ class MailListV2Es2 extends Base { | ||
440 | private function countHot($body,$folder){ | 441 | private function countHot($body,$folder){ |
441 | $body['query']['bool']['must'][] = ['term'=>['is_hots'=>1]]; | 442 | $body['query']['bool']['must'][] = ['term'=>['is_hots'=>1]]; |
442 | $body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]]; | 443 | $body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]]; |
443 | - $body['query']['bool']['must'][] = $this->assignSql3($folder); | 444 | + if($this->assignSql3($folder)) |
445 | + $body['query']['bool']['must'][] = $this->assignSql3($folder); | ||
446 | + logs('hot hot:'.json_encode($body)); | ||
444 | return $this->es->count($body); | 447 | return $this->es->count($body); |
445 | } | 448 | } |
446 | 449 | ||
@@ -468,9 +471,11 @@ class MailListV2Es2 extends Base { | @@ -468,9 +471,11 @@ class MailListV2Es2 extends Base { | ||
468 | if($seen!==null){ | 471 | if($seen!==null){ |
469 | $body['query']['bool']['must'][] = ['term'=>['seen'=>$seen]]; | 472 | $body['query']['bool']['must'][] = ['term'=>['seen'=>$seen]]; |
470 | } | 473 | } |
471 | - $body['query']['bool']['must'][] = ['term'=>['is_hots'=>0]]; | 474 | + if(in_array($folder,['收件箱','发件箱'])) |
475 | + $body['query']['bool']['must'][] = ['term'=>['is_hots'=>0]]; | ||
472 | $body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]]; | 476 | $body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]]; |
473 | - $body['query']['bool']['must'][] = $this->assignSql($folder); | 477 | + if($this->assignSql($folder)) $body['query']['bool']['must'][] = $this->assignSql($folder); |
478 | + logs('count :'.json_encode($body)); | ||
474 | return $this->es->count($body); | 479 | return $this->es->count($body); |
475 | } | 480 | } |
476 | 481 | ||
@@ -483,7 +488,8 @@ class MailListV2Es2 extends Base { | @@ -483,7 +488,8 @@ class MailListV2Es2 extends Base { | ||
483 | */ | 488 | */ |
484 | private function countFlagged($body){ | 489 | private function countFlagged($body){ |
485 | $body['query']['bool']['must'][] = ['term'=>['flagged'=>1]]; | 490 | $body['query']['bool']['must'][] = ['term'=>['flagged'=>1]]; |
486 | - $body['query']['bool']['must'][] = $this->assignSql('收件箱'); | 491 | + if($this->assignSql('收件箱')) |
492 | + $body['query']['bool']['must'][] = $this->assignSql('收件箱'); | ||
487 | return $this->es->count($body); | 493 | return $this->es->count($body); |
488 | } | 494 | } |
489 | 495 |
@@ -170,6 +170,7 @@ class SyncMail { | @@ -170,6 +170,7 @@ class SyncMail { | ||
170 | $login = $this->imap->login(); | 170 | $login = $this->imap->login(); |
171 | if(!$login->isOk()){ | 171 | if(!$login->isOk()){ |
172 | foreach ([ | 172 | foreach ([ |
173 | + 'Invalid login or password', | ||
173 | '[ALERT] Invalid credentials (Failure)',// 登录失败 | 174 | '[ALERT] Invalid credentials (Failure)',// 登录失败 |
174 | '[AUTHENTICATIONFAILED] Invalid credentials (Failure)',// 登录失败 | 175 | '[AUTHENTICATIONFAILED] Invalid credentials (Failure)',// 登录失败 |
175 | '[AUTHENTICATIONFAILED] Authentication failed.',// 登录失败 权限 | 176 | '[AUTHENTICATIONFAILED] Authentication failed.',// 登录失败 权限 |
@@ -602,7 +603,7 @@ class SyncMail { | @@ -602,7 +603,7 @@ class SyncMail { | ||
602 | 'encode' => $itemBody->data->get('content-transfer-encoding'), | 603 | 'encode' => $itemBody->data->get('content-transfer-encoding'), |
603 | 'name' => $itemBody->getFilename(), | 604 | 'name' => $itemBody->getFilename(), |
604 | 'filename' => $itemBody->getFilename(), | 605 | 'filename' => $itemBody->getFilename(), |
605 | - 'path' => $itemBody->save(MAIL_ATTACHMENT_PATH) | 606 | + 'path' => $itemBody->save(MAIL_ATTACHMENT_PATH.$this->emailId().'/') |
606 | ]; | 607 | ]; |
607 | if(!$tmp['path']){ | 608 | if(!$tmp['path']){ |
608 | throw new \Exception('请检查附件是否有写入权限 data id '.$id); | 609 | throw new \Exception('请检查附件是否有写入权限 data id '.$id); |
-
请 注册 或 登录 后发表评论