作者 张关杰

serve submit

... ... @@ -6,6 +6,7 @@ public/temp
public/attachment
public/attachment2
public/attachment2025
public/attachments
index.html
eml
log
... ...
... ... @@ -154,8 +154,8 @@ class SyncToEsCmd {
* @time 2025/5/29 11:47
*/
public function getPostid($email_id){
$data = redis()->getSet('fob_bind_mail:'.$email_id,300,function ($email_id){
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");
$data = redis()->getSet('fob_bind_mailx:'.$email_id,300,function ($email_id){
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");
},$email_id);
return [
... ...
... ... @@ -834,6 +834,7 @@ class Home extends Base {
// 全部标记
if(!$mail_ids){
app()->e('标记失败');
$folder = app()->request('folder','收件箱','folderAlias');
// 查询 当前的 文件夹 如果有选中文件夹 就 查询出 选中文件夹的id
$fids = db()->all(folderSql::all(array_column($emails,'id'),'`id`,`folder`'));
... ... @@ -995,14 +996,17 @@ class Home extends Base {
$data['allowreply'] = db()->value(folderSql::first(['id'=>$data['folder_id']],'folder'))!='发件箱'?1:0;
$body = db()->first(bodySql::first($id));
if(!$body){
if(empty($body['text_html'])){
$body = db()->first("select * from `bodies_back` where `lists_id` = ".$id." limit 1");
// if(!$body){
// $body = @file_get_contents('http://172.19.0.5:9527?id='.$id);
// if($body){
// $body = ['lists_id'=>$id,'text_html'=>$body];
// }
// }
if(empty($body['text_html'])){
$body = @file_get_contents('http://172.19.0.5:9527?id='.$id);
if($body){
$body = ['lists_id'=>$id,'text_html'=>$body];
}
}
}
if(empty($body['text_html'])){
$body = [];
}
if($body && !$reload){
$data['body'] = json_decode($body['text_html'],true);
... ...
... ... @@ -234,6 +234,17 @@ class MailListV2Es extends Base {
$notinquery[] = ['match_phrase'=>['from.email'=>$sub]];
}
}
// $no_subject = app()->request('subject');
// if ($no_subject) {
// $no_subject = is_array($no_subject) ? $no_subject : [$no_subject];
// foreach ($no_subject as $k => $sub) {
// if($sub){
// $notinquery[] = ['match_phrase'=>['subject'=>$sub]];
// }
// }
// }
if($notinquery){
$query['bool']['must_not'] = $notinquery;
}
... ... @@ -242,7 +253,7 @@ class MailListV2Es extends Base {
// $result = $this->es->search(['query'=>$query],($page-1) * $limit,$limit,['udate'=>"desc"]);
$result = $this->es->search(['query'=>['constant_score'=>['filter'=>$query]]],($page-1) * $limit,$limit,['udate'=>"desc"],($where['is_hots']==1||$folder=='垃圾箱')?10000:true);
$result = $this->es->search(['query'=>['constant_score'=>['filter'=>$query]]],($page-1) * $limit,$limit,['udate'=>"desc"],(($where['is_hots']??0)==1||$folder=='垃圾箱')?10000:true);
$total = $result['hits']['total']['value']??0;
... ... @@ -282,7 +293,7 @@ class MailListV2Es extends Base {
}
// 手动触发同步es
redis()->rPush('sync_to_es',$v['id']);
if(empty($v['is_auto']) && $v['folder_name']=='收件箱') redis()->rPush('sync_to_es',$v['id']);
return $v;
},$lists?:[]);
... ...
... ... @@ -180,7 +180,7 @@ class MailListV2Es2 extends Base {
// 软删
$where['deleted'] = 0;
$where['source'] = 2; // ai邮件群体
// $where['email_id'] = $this->getEmails('id');
if(count($this->getEmails('id')) == 1) $where['email_id'] = $this->getEmails('id');
$query = [
'bool'=>[
... ... @@ -235,7 +235,7 @@ class MailListV2Es2 extends Base {
}
}
// logs(json_encode(['query'=>['constant_score'=>['filter'=>$query]]]));
logs('lists '.json_encode(['query'=>['constant_score'=>['filter'=>$query]]]));
$result = $this->es->search(['query'=>['constant_score'=>['filter'=>$query]]],($page-1) * $limit,$limit,['udate'=>"desc"]);
... ... @@ -357,6 +357,7 @@ class MailListV2Es2 extends Base {
]
]
];
if(count($this->getEmails('id')) == 1) $body['query']['bool']['must'][] = ['terms'=>['email_id'=>$this->getEmails('id')]];
// 时间 必须是数组
$udate = app()->request('udate');
if($udate && is_array($udate) && count($udate) == 2){
... ... @@ -440,7 +441,9 @@ class MailListV2Es2 extends Base {
private function countHot($body,$folder){
$body['query']['bool']['must'][] = ['term'=>['is_hots'=>1]];
$body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]];
$body['query']['bool']['must'][] = $this->assignSql3($folder);
if($this->assignSql3($folder))
$body['query']['bool']['must'][] = $this->assignSql3($folder);
logs('hot hot:'.json_encode($body));
return $this->es->count($body);
}
... ... @@ -468,9 +471,11 @@ class MailListV2Es2 extends Base {
if($seen!==null){
$body['query']['bool']['must'][] = ['term'=>['seen'=>$seen]];
}
$body['query']['bool']['must'][] = ['term'=>['is_hots'=>0]];
if(in_array($folder,['收件箱','发件箱']))
$body['query']['bool']['must'][] = ['term'=>['is_hots'=>0]];
$body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]];
$body['query']['bool']['must'][] = $this->assignSql($folder);
if($this->assignSql($folder)) $body['query']['bool']['must'][] = $this->assignSql($folder);
logs('count :'.json_encode($body));
return $this->es->count($body);
}
... ... @@ -483,7 +488,8 @@ class MailListV2Es2 extends Base {
*/
private function countFlagged($body){
$body['query']['bool']['must'][] = ['term'=>['flagged'=>1]];
$body['query']['bool']['must'][] = $this->assignSql('收件箱');
if($this->assignSql('收件箱'))
$body['query']['bool']['must'][] = $this->assignSql('收件箱');
return $this->es->count($body);
}
... ...
... ... @@ -170,6 +170,7 @@ class SyncMail {
$login = $this->imap->login();
if(!$login->isOk()){
foreach ([
'Invalid login or password',
'[ALERT] Invalid credentials (Failure)',// 登录失败
'[AUTHENTICATIONFAILED] Invalid credentials (Failure)',// 登录失败
'[AUTHENTICATIONFAILED] Authentication failed.',// 登录失败 权限
... ... @@ -602,7 +603,7 @@ class SyncMail {
'encode' => $itemBody->data->get('content-transfer-encoding'),
'name' => $itemBody->getFilename(),
'filename' => $itemBody->getFilename(),
'path' => $itemBody->save(MAIL_ATTACHMENT_PATH)
'path' => $itemBody->save(MAIL_ATTACHMENT_PATH.$this->emailId().'/')
];
if(!$tmp['path']){
throw new \Exception('请检查附件是否有写入权限 data id '.$id);
... ...