作者 邓超

同步

... ... @@ -14,17 +14,9 @@ function start(){
if($id && is_numeric($id)){
// 占用当前的id,占用2小时
if(redis()->add('just_sync_'.$id,time(),600)){
try{
// 开始同步
(new \Service\SyncMail($id))->sync();
}catch (Throwable $e){
logs('sync : '.$e->getMessage());
}
// 30秒后 消除占用
redis()->expire('just_sync_'.$id,60);
// 写入日志
\Lib\Log::getInstance()->write();
go(function () use ($id){
echo file_get_contents(APP_HOST.'v3/sync?id='.$id);
});
}
}else{
co::sleep(1);
... ...
<?php
namespace Controller\v3;
use Controller\Base;
use Lib\Mail\Mail;
use Lib\Mail\MailFun;
use Lib\UploadFile;
use Lib\Verify;
use Model\bodySql;
use Model\emailSql;
use Model\folderSql;
use Model\listsSql;
use Model\sendJobsSql;
use Service\SyncMail;
use function Co\run;
use function Swoole\Coroutine\Http\request;
/**
* @author:dc
* @time 2023/2/13 11:28
* Class Home
* @package Controller
*/
class Home extends Base {
/**
* v3 版本
* 同步邮件
* @return string
* @throws \Lib\Err
* @author:dc
* @time 2023/8/2 16:19
*/
public function sync(){
$id = app()->request('id');
if($id && is_numeric($id)){
(new SyncMail($id))->sync();
}
}
}
... ...
... ... @@ -39,6 +39,7 @@ return [
'sync' => [\Controller\Home::class, 'sync'],
// v2 版本的
'v2/sync' => [\Controller\v2\Home::class, 'sync'],
'v3/sync' => [\Controller\v3\Home::class, 'sync'],
// 标记为已读
'seen_2_unseen' => [\Controller\Home::class, 'seen_2_unseen'],
// 标记为已回复/未回复
... ...