作者 邓超

xxx

... ... @@ -458,6 +458,13 @@ class Home extends Base {
* @time 2023/3/21 11:41
*/
public function move(){
$this->moveCopy(function (Mail $mailInstance,$uid,$origin_folder,$to_origin_folder){
return $mailInstance->move($uid,$origin_folder,$to_origin_folder);
});
}
private function moveCopy(\Closure $call){
$emails = $this->getEmails();
$mail_ids = app()->request('mail_ids');
... ... @@ -520,15 +527,16 @@ class Home extends Base {
$mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
if($mailInstance->login()){
$ret = $call($mailInstance,array_column($uid,'uid'),$folder['origin_folder'],$to_origin_folder['origin_folder']);
// TODO:: 这个过程无法保证原子性。没办法
// 先复制
$ret = $mailInstance->move(array_column($uid,'uid'),$folder['origin_folder'],$to_origin_folder['origin_folder']);
if($ret){
$uret = db()->update(listsSql::$table,['deleted'=>1],dbWhere(['id'=>array_column($uid,'id')]));
}
$mailInstance = null;
}
$mailInstance = null;
}
$folder = null;
... ... @@ -547,6 +555,21 @@ class Home extends Base {
}
/**
* 复制邮件
* @throws \Lib\Err
* @author:dc
* @time 2024/3/9 13:50
*/
public function copy(){
$this->moveCopy(function (Mail $mailInstance,$uid,$origin_folder,$to_origin_folder){
return $mailInstance->copy($uid,$origin_folder,$to_origin_folder);
});
}
/**
... ...
... ... @@ -36,6 +36,8 @@ return [
'answered_2_unanswered' => [\Controller\Home::class, 'answered_2_unanswered'],
// 邮件移动文件夹
'move' => [\Controller\Home::class, 'move'],
// 复制邮件
'copy' => [\Controller\Home::class, 'copy'],
// 检查邮箱状态
'check' => [\Controller\Home::class, 'check'],
... ...