...
|
...
|
@@ -2,9 +2,11 @@ |
|
|
|
|
|
namespace Controller;
|
|
|
|
|
|
use Lib\Mail\Mail;
|
|
|
use Lib\Mail\MailFun;
|
|
|
use Lib\Verify;
|
|
|
use Model\emailSql;
|
|
|
use Model\folderSql;
|
|
|
use Model\listsSql;
|
|
|
|
|
|
|
...
|
...
|
@@ -144,6 +146,74 @@ class Home extends Base { |
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 标记为已读
|
|
|
* @throws \Lib\Err
|
|
|
* @author:dc
|
|
|
* @time 2023/3/17 16:15
|
|
|
*/
|
|
|
public function seen_2_unseen(){
|
|
|
$emails = $this->getEmails();
|
|
|
|
|
|
$mail_ids = app()->request('mail_ids');
|
|
|
foreach ($mail_ids as $k=>$id){
|
|
|
if(!is_numeric($id)){
|
|
|
unset($mail_ids[$k]);
|
|
|
}
|
|
|
}
|
|
|
// 已读或未读
|
|
|
$seen = (int) app()->request('seen');
|
|
|
$seen = $seen ? 1 : 0;
|
|
|
|
|
|
$data = db()->all(listsSql::first(dbWhere(['id'=>$mail_ids,'email_id'=>array_column($emails,'id')])));
|
|
|
if($data){
|
|
|
// 查询邮箱
|
|
|
$emails = array_column($emails,null,'id');
|
|
|
$uids = [];
|
|
|
foreach ($data as $datum){
|
|
|
if(empty($uids[$datum['email_id']])){
|
|
|
$uids[$datum['email_id']][$datum['folder_id']] = [];
|
|
|
}
|
|
|
$uids[$datum['email_id']][$datum['folder_id']][] = [
|
|
|
'uid' => $datum['uid'],
|
|
|
'id' => $datum['id'],
|
|
|
];
|
|
|
}
|
|
|
|
|
|
foreach ($uids as $eid=>$arr){
|
|
|
foreach ($arr as $fid=>$uid){
|
|
|
// 查询目录
|
|
|
$folder = db()->first(folderSql::first($fid));
|
|
|
if($folder){
|
|
|
// 开始远程
|
|
|
$mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
|
|
|
|
|
|
$mailInstance->login();
|
|
|
|
|
|
$mailInstance->seen(array_column($uid,'uid'),$folder['origin_folder'],$seen);
|
|
|
|
|
|
$mailInstance = null;
|
|
|
// 更新数据
|
|
|
db()->update(listsSql::$table,[
|
|
|
'seen' => $seen
|
|
|
],dbWhere([
|
|
|
'id' => array_column($uid,'id')
|
|
|
]));
|
|
|
|
|
|
}
|
|
|
$folder = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
app()->_json([
|
|
|
'mail_id' => $mail_ids
|
|
|
]);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
...
|
...
|
|