正在显示
1 个修改的文件
包含
45 行增加
和
4 行删除
@@ -55,6 +55,12 @@ class SyncMail { | @@ -55,6 +55,12 @@ class SyncMail { | ||
55 | */ | 55 | */ |
56 | protected $isForceUpdate = false; | 56 | protected $isForceUpdate = false; |
57 | 57 | ||
58 | + /** | ||
59 | + * 是否输出日志 | ||
60 | + * @var bool | ||
61 | + */ | ||
62 | + protected $echoLog = false; | ||
63 | + | ||
58 | 64 | ||
59 | /** | 65 | /** |
60 | * SyncMail constructor. | 66 | * SyncMail constructor. |
@@ -94,6 +100,27 @@ class SyncMail { | @@ -94,6 +100,27 @@ class SyncMail { | ||
94 | } | 100 | } |
95 | 101 | ||
96 | /** | 102 | /** |
103 | + * @param bool $echoLog | ||
104 | + */ | ||
105 | + public function setEchoLog() | ||
106 | + { | ||
107 | + $this->echoLog = true; | ||
108 | + return $this; | ||
109 | + } | ||
110 | + | ||
111 | + /** | ||
112 | + * 输出日志 | ||
113 | + * @param $msg | ||
114 | + * @author:dc | ||
115 | + * @time 2025/3/20 11:03 | ||
116 | + */ | ||
117 | + protected function eLog($msg){ | ||
118 | + if($this->echoLog){ | ||
119 | + _echo($msg); | ||
120 | + } | ||
121 | + } | ||
122 | + | ||
123 | + /** | ||
97 | * 搜索 | 124 | * 搜索 |
98 | * @param ImapSearch $search | 125 | * @param ImapSearch $search |
99 | * @return $this | 126 | * @return $this |
@@ -335,7 +362,7 @@ class SyncMail { | @@ -335,7 +362,7 @@ class SyncMail { | ||
335 | if(is_string($folder)){ | 362 | if(is_string($folder)){ |
336 | $folder = $this->imap->folder($folder)->exec(); | 363 | $folder = $this->imap->folder($folder)->exec(); |
337 | } | 364 | } |
338 | - | 365 | + $this->eLog("正在同步 ".$folder->getName()); |
339 | $folder_id = $this->getFolderId($folder->getName()); | 366 | $folder_id = $this->getFolderId($folder->getName()); |
340 | if($folder->getName() == 'INBOX'){ | 367 | if($folder->getName() == 'INBOX'){ |
341 | $this->folder_inbox_id = $folder_id; | 368 | $this->folder_inbox_id = $folder_id; |
@@ -461,12 +488,19 @@ class SyncMail { | @@ -461,12 +488,19 @@ class SyncMail { | ||
461 | ]),'`id`')); | 488 | ]),'`id`')); |
462 | 489 | ||
463 | if(!$id){ | 490 | if(!$id){ |
464 | - | ||
465 | - $id = $this->insert($data); | ||
466 | - // 收件箱直接 未读 不远程为准 | 491 | + $this->eLog( |
492 | + sprintf("正在插入数据 eid:%d fid:%d uid:%d subject: %s", | ||
493 | + $data['email_id'], | ||
494 | + $data['folder_id'], | ||
495 | + $data['uid'], | ||
496 | + $data['subject'], | ||
497 | + )); | ||
498 | + | ||
499 | +// 收件箱直接 未读 不远程为准 | ||
467 | if(defined('CLI_AI_SYNC_START') && !empty($this->folder_inbox_id) && $this->folder_inbox_id == $data['folder_id']){ | 500 | if(defined('CLI_AI_SYNC_START') && !empty($this->folder_inbox_id) && $this->folder_inbox_id == $data['folder_id']){ |
468 | $data['seen'] = 0; | 501 | $data['seen'] = 0; |
469 | } | 502 | } |
503 | + $id = $this->insert($data); | ||
470 | 504 | ||
471 | if(!$id){ | 505 | if(!$id){ |
472 | continue; | 506 | continue; |
@@ -482,6 +516,13 @@ class SyncMail { | @@ -482,6 +516,13 @@ class SyncMail { | ||
482 | }else{ | 516 | }else{ |
483 | // 非ai邮件才更新 | 517 | // 非ai邮件才更新 |
484 | if(!defined('CLI_AI_SYNC_START')){ | 518 | if(!defined('CLI_AI_SYNC_START')){ |
519 | + $this->eLog( | ||
520 | + sprintf("正在update数据 eid:%d fid:%d uid:%d subject: %s", | ||
521 | + $data['email_id'], | ||
522 | + $data['folder_id'], | ||
523 | + $data['uid'], | ||
524 | + $data['subject'], | ||
525 | + )); | ||
485 | $this->db->update(listsSql::$table,$data,dbWhere(['id'=> $id])); | 526 | $this->db->update(listsSql::$table,$data,dbWhere(['id'=> $id])); |
486 | } | 527 | } |
487 | 528 |
-
请 注册 或 登录 后发表评论