|
@@ -23,327 +23,46 @@ use function Swoole\Coroutine\Http\request; |
|
@@ -23,327 +23,46 @@ use function Swoole\Coroutine\Http\request; |
|
23
|
* Class Home
|
23
|
* Class Home
|
|
24
|
* @package Controller
|
24
|
* @package Controller
|
|
25
|
*/
|
25
|
*/
|
|
26
|
-class Home extends Base {
|
26
|
+class Home extends Base
|
|
|
|
27
|
+{
|
|
27
|
|
28
|
|
|
28
|
|
29
|
|
|
29
|
/**
|
30
|
/**
|
|
30
|
- * 邮件列表
|
|
|
|
31
|
- * @author:dc
|
|
|
|
32
|
- * @time 2023/2/17 14:12
|
|
|
|
33
|
- */
|
|
|
|
34
|
- public function lists(){
|
|
|
|
35
|
-
|
|
|
|
36
|
- // 分页 页数
|
|
|
|
37
|
- $page = app()->request('page',1,'intval');
|
|
|
|
38
|
- $page = $page ? $page : 1;
|
|
|
|
39
|
-
|
|
|
|
40
|
- $limit = app()->request('limit',20,'intval');
|
|
|
|
41
|
- $limit = $limit ? $limit : 1;
|
|
|
|
42
|
-
|
|
|
|
43
|
- // 指定id
|
|
|
|
44
|
- $ids = app()->request('mail_id');
|
|
|
|
45
|
- $ids = is_array($ids) ? $ids : [$ids];
|
|
|
|
46
|
- foreach ($ids as $i=>$d){
|
|
|
|
47
|
- if(!is_numeric($d)){
|
|
|
|
48
|
- unset($ids[$i]);
|
|
|
|
49
|
- }
|
|
|
|
50
|
- }
|
|
|
|
51
|
-
|
|
|
|
52
|
- // 附件
|
|
|
|
53
|
- $attachment = app()->request('attachment',0,'bool_Val');
|
|
|
|
54
|
- // 已读/未读
|
|
|
|
55
|
- $seen = app()->request('seen',-1,'intval');
|
|
|
|
56
|
- // 软删
|
|
|
|
57
|
- $deleted = app()->request('deleted',0,'intval');
|
|
|
|
58
|
-
|
|
|
|
59
|
-
|
|
|
|
60
|
- $where = ['email_id'=>$this->getEmails('id')];
|
|
|
|
61
|
-
|
|
|
|
62
|
-
|
|
|
|
63
|
- $folder_id = ['-'];
|
|
|
|
64
|
- if (app()->requestArr('folder_id')){
|
|
|
|
65
|
- $folder_id = app()->requestArr('folder_id');
|
|
|
|
66
|
- }else{
|
|
|
|
67
|
- // 目录
|
|
|
|
68
|
- $folder = app()->request('folder','收件箱','folderAlias');
|
|
|
|
69
|
- if($folder !== true || $folder!=='true'){
|
|
|
|
70
|
- $folderList = db()->all(folderSql::all($where['email_id']));
|
|
|
|
71
|
-
|
|
|
|
72
|
- // 文件夹id
|
|
|
|
73
|
- if($folderList){
|
|
|
|
74
|
- foreach ($folderList as $item){
|
|
|
|
75
|
- if(
|
|
|
|
76
|
- // 数组文件夹
|
|
|
|
77
|
- (is_array($folder) && in_array($item['folder'],$folder))
|
|
|
|
78
|
- || $item['folder'] == $folder
|
|
|
|
79
|
- ){
|
|
|
|
80
|
- $folder_id[] = $item['id'];
|
|
|
|
81
|
- }
|
|
|
|
82
|
- }
|
|
|
|
83
|
- }
|
|
|
|
84
|
- }
|
|
|
|
85
|
-
|
|
|
|
86
|
- }
|
|
|
|
87
|
-
|
|
|
|
88
|
- if(!$folder_id){
|
|
|
|
89
|
- app()->e('folder_not_fount');
|
|
|
|
90
|
- }
|
|
|
|
91
|
- $folder_id = array_filter($folder_id,'is_int');
|
|
|
|
92
|
-
|
|
|
|
93
|
- //目录
|
|
|
|
94
|
- if($folder_id) $where['folder_id'] = array_values($folder_id);
|
|
|
|
95
|
- if($ids) $where['id'] = $ids;
|
|
|
|
96
|
-
|
|
|
|
97
|
- if(paramHas('attachment')){
|
|
|
|
98
|
- $where['is_file'] = $attachment ? 1 : 0; //附件
|
|
|
|
99
|
- }
|
|
|
|
100
|
-
|
|
|
|
101
|
-
|
|
|
|
102
|
- // 软删
|
|
|
|
103
|
- $where['deleted'] = $deleted;
|
|
|
|
104
|
- // 已读/未读
|
|
|
|
105
|
- if(paramHas('seen')){
|
|
|
|
106
|
- if(in_array($seen,[0,1])){
|
|
|
|
107
|
- $where['seen'] = $seen;
|
|
|
|
108
|
- }
|
|
|
|
109
|
- }
|
|
|
|
110
|
-
|
|
|
|
111
|
- $where['_'] = [];
|
|
|
|
112
|
- // 搜索关键字
|
|
|
|
113
|
- $keyword = app()->request('keyword','',['htmlspecialchars','addslashes']);
|
|
|
|
114
|
- if($keyword){
|
|
|
|
115
|
- $where['_'][] = '`subject` like "%'.$keyword.'%"';
|
|
|
|
116
|
- }
|
|
|
|
117
|
-
|
|
|
|
118
|
- // 那个发的
|
|
|
|
119
|
- $address = app()->request('address');
|
|
|
|
120
|
- if($address){
|
|
|
|
121
|
- if(is_array($address)){
|
|
|
|
122
|
- // 发贱人
|
|
|
|
123
|
- if(Verify::sEmail($address['from']??'')){
|
|
|
|
124
|
- $where['from'] = $address['from'];
|
|
|
|
125
|
- }
|
|
|
|
126
|
- // 收件人
|
|
|
|
127
|
- if(Verify::sEmail($address['to']??'')){
|
|
|
|
128
|
- $where['_'][] = '`to_name` like "%'.$address.'%"';
|
|
|
|
129
|
- }
|
|
|
|
130
|
-
|
|
|
|
131
|
- }else if(Verify::sEmail($address)){
|
|
|
|
132
|
- // 收件人/发件人
|
|
|
|
133
|
- $where['_'][] = '(`from` = "'.$address.'" or `to_name` like "%'.$address.'%")';
|
|
|
|
134
|
- }
|
|
|
|
135
|
- }
|
|
|
|
136
|
- // from 搜索收件人
|
|
|
|
137
|
- if(app()->requestHas('from')){
|
|
|
|
138
|
- // 如果是发件箱
|
|
|
|
139
|
- if($folder == '发件箱'){
|
|
|
|
140
|
- $tos = app()->request('from');
|
|
|
|
141
|
- if(!$tos){
|
|
|
|
142
|
- // 不让查询数据
|
|
|
|
143
|
- $where['id'] = 0;
|
|
|
|
144
|
- }else {
|
|
|
|
145
|
- $tos = array_map(function ($v){
|
|
|
|
146
|
- return "find_in_set('".addcslashes($v,"'")."',`to`)";
|
|
|
|
147
|
- },is_array($tos) ? $tos : [$tos]);
|
|
|
|
148
|
-
|
|
|
|
149
|
- $where['_'][] = '('.implode(' or ',$tos).')';
|
|
|
|
150
|
- }
|
|
|
|
151
|
- }else{
|
|
|
|
152
|
- $where['from'] = app()->request('from');
|
|
|
|
153
|
- if(!$where['from']){
|
|
|
|
154
|
- // 不让查询数据
|
|
|
|
155
|
- $where['id'] = 0;
|
|
|
|
156
|
- }
|
|
|
|
157
|
- }
|
|
|
|
158
|
-
|
|
|
|
159
|
-
|
|
|
|
160
|
- }
|
|
|
|
161
|
-
|
|
|
|
162
|
-
|
|
|
|
163
|
- // 回复
|
|
|
|
164
|
- if (paramHas('answered')){
|
|
|
|
165
|
- $where['answered'] = app()->request('answered',0,'bool_Val')?1:0;
|
|
|
|
166
|
- }
|
|
|
|
167
|
-
|
|
|
|
168
|
- // 这个主要是来筛选 是否是自己发送的
|
|
|
|
169
|
- $fromto = app()->request('formorto');
|
|
|
|
170
|
- if($fromto=='from'){
|
|
|
|
171
|
- $where['from'] = $this->getEmails('email');
|
|
|
|
172
|
- }elseif ($fromto=='to'){
|
|
|
|
173
|
- $where['from.notin'] = $this->getEmails('email');
|
|
|
|
174
|
- }
|
|
|
|
175
|
-
|
|
|
|
176
|
- /**
|
|
|
|
177
|
- * 不查询哪些发件人的邮件
|
|
|
|
178
|
- */
|
|
|
|
179
|
- $form_not_in = app()->request('from_not_in');
|
|
|
|
180
|
- if($form_not_in){
|
|
|
|
181
|
- $form_not_in = is_array($form_not_in) ? $form_not_in : [$form_not_in];
|
|
|
|
182
|
- $form_not_in = array_filter($form_not_in,function ($v){
|
|
|
|
183
|
- if(is_string($v) && Verify::sEmail($v)){
|
|
|
|
184
|
- return true;
|
|
|
|
185
|
- }
|
|
|
|
186
|
- return false;
|
|
|
|
187
|
- });
|
|
|
|
188
|
- if($form_not_in){
|
|
|
|
189
|
- if(isset($where['from.notin'])){
|
|
|
|
190
|
- $where['from.notin'] = array_merge($where['from.notin'],$form_not_in);
|
|
|
|
191
|
- }else{
|
|
|
|
192
|
- $where['from.notin'] = $form_not_in;
|
|
|
|
193
|
- }
|
|
|
|
194
|
-
|
|
|
|
195
|
- }
|
|
|
|
196
|
- }
|
|
|
|
197
|
- if(!empty($where['from.notin'])){
|
|
|
|
198
|
- $where['from.notin'] = array_unique($where['from.notin']);
|
|
|
|
199
|
- }
|
|
|
|
200
|
-
|
|
|
|
201
|
-
|
|
|
|
202
|
-
|
|
|
|
203
|
- $lists = db()->all(
|
|
|
|
204
|
- listsSql::lists(
|
|
|
|
205
|
- dbWhere($where),
|
|
|
|
206
|
- $page,
|
|
|
|
207
|
- $limit
|
|
|
|
208
|
- )
|
|
|
|
209
|
- );
|
|
|
|
210
|
- $lists = $lists ? $lists : [];
|
|
|
|
211
|
-
|
|
|
|
212
|
- // map
|
|
|
|
213
|
- $lists = array_map(function ($v){
|
|
|
|
214
|
- $v['uuid'] = get_email_uuid($v['subject'],$v['udate'],$v['from'],$v['to'],$v['size']);
|
|
|
|
215
|
- if(!empty($v['description'])){
|
|
|
|
216
|
- $v['description'] = @html_entity_decode($v['description'], ENT_COMPAT, 'UTF-8');
|
|
|
|
217
|
- }
|
|
|
|
218
|
- $v['to_name'] = @json_decode($v['to_name'],true);
|
|
|
|
219
|
- $v['to_name'] = $v['to_name']?:[];
|
|
|
|
220
|
- if($v['to_name']){
|
|
|
|
221
|
- if(!empty($v['to_name'][0]['email'])){
|
|
|
|
222
|
- $v['to'] = $v['to_name'][0]['email'];
|
|
|
|
223
|
- }
|
|
|
|
224
|
- $v['to_name'] = MailFun::mb_coding($v['to_name'][0]['name']??'');
|
|
|
|
225
|
- }
|
|
|
|
226
|
- if(is_array($v['to_name'])){
|
|
|
|
227
|
- $v['to_name'] = '';
|
|
|
|
228
|
- }
|
|
|
|
229
|
- // 邮件箱
|
|
|
|
230
|
- $v['folder_name'] = db()->cache(86400)->value(folderSql::first($v['folder_id'],'folder'));
|
|
|
|
231
|
- return $v;
|
|
|
|
232
|
- },$lists);
|
|
|
|
233
|
-
|
|
|
|
234
|
- // 总数
|
|
|
|
235
|
- $total = db()->count(
|
|
|
|
236
|
- listsSql::listCount(dbWhere($where))
|
|
|
|
237
|
- );
|
|
|
|
238
|
-
|
|
|
|
239
|
- app()->_json(listsPage($lists,$total,$page,$limit));
|
|
|
|
240
|
-
|
|
|
|
241
|
- }
|
|
|
|
242
|
-
|
|
|
|
243
|
- /**
|
|
|
|
244
|
- * 统计
|
|
|
|
245
|
- * @throws \Lib\Err
|
|
|
|
246
|
- * @author:dc
|
|
|
|
247
|
- * @time 2024/10/14 16:20
|
|
|
|
248
|
- */
|
|
|
|
249
|
- public function count()
|
|
|
|
250
|
- {
|
|
|
|
251
|
-
|
|
|
|
252
|
- $where = [];
|
|
|
|
253
|
-
|
|
|
|
254
|
-
|
|
|
|
255
|
- $start_time = app()->request('start_time',0,'intval');
|
|
|
|
256
|
- $end_time = app()->request('end_time',0,'intval');
|
|
|
|
257
|
-// if($start_time || $end_time){
|
|
|
|
258
|
-// $where['email_id'] = $this->getEmails('id');
|
|
|
|
259
|
-// }
|
|
|
|
260
|
- $where['_'] = [];
|
|
|
|
261
|
- if($start_time){
|
|
|
|
262
|
- $where['_'][] = '`udate` >= '.$start_time;
|
|
|
|
263
|
- }
|
|
|
|
264
|
- if($end_time){
|
|
|
|
265
|
- $where['_'][] = '`udate` <= '.$end_time;
|
|
|
|
266
|
- }
|
|
|
|
267
|
-
|
|
|
|
268
|
- $where['_'] && $where['_'] = implode(' and ',$where['_']);
|
|
|
|
269
|
-
|
|
|
|
270
|
- $where['folder_id'] = [];
|
|
|
|
271
|
-
|
|
|
|
272
|
- // 目录
|
|
|
|
273
|
- $folderList = db()->all(folderSql::all($this->getEmails('id')));
|
|
|
|
274
|
-
|
|
|
|
275
|
- // 文件夹id
|
|
|
|
276
|
- foreach ($folderList as $item) {
|
|
|
|
277
|
- if ($item['folder'] == '收件箱') {
|
|
|
|
278
|
- $where['folder_id'][] = $item['id'];
|
|
|
|
279
|
- }
|
|
|
|
280
|
- }
|
|
|
|
281
|
-
|
|
|
|
282
|
-
|
|
|
|
283
|
- // 软删
|
|
|
|
284
|
- $where['deleted'] = 0;
|
|
|
|
285
|
-
|
|
|
|
286
|
- // 总数
|
|
|
|
287
|
- $inbox = db()->cache(3600)->count(listsSql::listCount(dbWhere($where)));
|
|
|
|
288
|
-
|
|
|
|
289
|
- if(app()->request('show')=='inbox'){
|
|
|
|
290
|
- app()->_json(['inbox'=>$inbox]);
|
|
|
|
291
|
- }
|
|
|
|
292
|
-
|
|
|
|
293
|
- // 未读
|
|
|
|
294
|
- $where['seen'] = 0;
|
|
|
|
295
|
- $unseen = db()->cache(3600)->count(listsSql::listCount(dbWhere($where)));
|
|
|
|
296
|
-
|
|
|
|
297
|
-
|
|
|
|
298
|
- $where['folder_id'] = [];
|
|
|
|
299
|
- foreach ($folderList as $item) {
|
|
|
|
300
|
- if ($item['folder'] == '发件箱') {
|
|
|
|
301
|
- $where['folder_id'][] = $item['id'];
|
|
|
|
302
|
- }
|
|
|
|
303
|
- }
|
|
|
|
304
|
- unset($where['seen']);
|
|
|
|
305
|
- //发件箱
|
|
|
|
306
|
- $send = db()->cache(3600)->count(listsSql::listCount(dbWhere($where)));
|
|
|
|
307
|
-
|
|
|
|
308
|
- app()->_json(['inbox'=>$inbox,'unseen'=>$unseen,'send'=>$send]);
|
|
|
|
309
|
- }
|
|
|
|
310
|
-
|
|
|
|
311
|
- /**
|
|
|
|
312
|
* 检测邮箱状态
|
31
|
* 检测邮箱状态
|
|
313
|
* @author:dc
|
32
|
* @author:dc
|
|
314
|
* @time 2023/3/28 16:19
|
33
|
* @time 2023/3/28 16:19
|
|
315
|
*/
|
34
|
*/
|
|
316
|
- public function check(){
|
|
|
|
317
|
-
|
35
|
+ public function check()
|
|
|
|
36
|
+ {
|
|
318
|
|
37
|
|
|
319
|
|
38
|
|
|
320
|
- $lists = db()->all(emailSql::getValues(['email'=>web_request_emails()],'`id`,`pwd_error`,`email`,`password`,`imap`'));
|
|
|
|
321
|
- if(count($lists)>1){
|
|
|
|
322
|
- return array_column($lists,'pwd_error','email');
|
39
|
+ $lists = db()->all(emailSql::getValues(['email' => web_request_emails()], '`id`,`pwd_error`,`email`,`password`,`imap`'));
|
|
|
|
40
|
+ if (count($lists) > 1) {
|
|
|
|
41
|
+ return array_column($lists, 'pwd_error', 'email');
|
|
323
|
}
|
42
|
}
|
|
324
|
|
43
|
|
|
325
|
- foreach ($lists as $k=>$list){
|
44
|
+ foreach ($lists as $k => $list) {
|
|
326
|
// if(!$list['pwd_error']){
|
45
|
// if(!$list['pwd_error']){
|
|
327
|
- $list['host'] = $list['imap'];
|
|
|
|
328
|
- $list['password'] = base64_decode($list['password']);
|
|
|
|
329
|
- $imap = ImapPool::get(new ImapConfig($list));
|
|
|
|
330
|
- $n = $imap->login()->isOk();
|
|
|
|
331
|
- if($n){
|
|
|
|
332
|
- if($lists[$k]['pwd_error']){
|
|
|
|
333
|
- db()->update(emailSql::$table,['pwd_error'=>0],'`id` = '.$list['id']);
|
|
|
|
334
|
- }
|
|
|
|
335
|
- $lists[$k]['pwd_error'] = 0;
|
|
|
|
336
|
- }else{
|
|
|
|
337
|
- if(!$lists[$k]['pwd_error']){
|
|
|
|
338
|
- db()->update(emailSql::$table,['pwd_error'=>1],'`id` = '.$list['id']);
|
|
|
|
339
|
- }
|
|
|
|
340
|
- $lists[$k]['pwd_error'] = 1;
|
46
|
+ $list['host'] = $list['imap'];
|
|
|
|
47
|
+ $list['password'] = base64_decode($list['password']);
|
|
|
|
48
|
+ $imap = ImapPool::get(new ImapConfig($list));
|
|
|
|
49
|
+ $n = $imap->login()->isOk();
|
|
|
|
50
|
+ if ($n) {
|
|
|
|
51
|
+ if ($lists[$k]['pwd_error']) {
|
|
|
|
52
|
+ db()->update(emailSql::$table, ['pwd_error' => 0], '`id` = ' . $list['id']);
|
|
341
|
}
|
53
|
}
|
|
|
|
54
|
+ $lists[$k]['pwd_error'] = 0;
|
|
|
|
55
|
+ } else {
|
|
|
|
56
|
+ if (!$lists[$k]['pwd_error']) {
|
|
|
|
57
|
+ db()->update(emailSql::$table, ['pwd_error' => 1], '`id` = ' . $list['id']);
|
|
|
|
58
|
+ }
|
|
|
|
59
|
+ $lists[$k]['pwd_error'] = 1;
|
|
|
|
60
|
+ }
|
|
342
|
// }
|
61
|
// }
|
|
343
|
|
62
|
|
|
344
|
}
|
63
|
}
|
|
345
|
|
64
|
|
|
346
|
- return array_column($lists,'pwd_error','email');
|
65
|
+ return array_column($lists, 'pwd_error', 'email');
|
|
347
|
|
66
|
|
|
348
|
}
|
67
|
}
|
|
349
|
|
68
|
|
|
@@ -353,35 +72,36 @@ class Home extends Base { |
|
@@ -353,35 +72,36 @@ class Home extends Base { |
|
353
|
* @author:dc
|
72
|
* @author:dc
|
|
354
|
* @time 2023/2/18 17:32
|
73
|
* @time 2023/2/18 17:32
|
|
355
|
*/
|
74
|
*/
|
|
356
|
- public function send_mail(){
|
75
|
+ public function send_mail()
|
|
|
|
76
|
+ {
|
|
357
|
|
77
|
|
|
358
|
$email = $this->getEmail();
|
78
|
$email = $this->getEmail();
|
|
359
|
|
79
|
|
|
360
|
- $yzemail = function(&$value,$field){
|
|
|
|
361
|
- if($value){
|
|
|
|
362
|
- if(!is_array($value)){
|
|
|
|
363
|
- if(@json_decode($value,true)){
|
|
|
|
364
|
- $value = json_decode($value,true);
|
|
|
|
365
|
- }else{
|
|
|
|
366
|
- $value = [['email'=>$value,'name'=>'']];
|
80
|
+ $yzemail = function (&$value, $field) {
|
|
|
|
81
|
+ if ($value) {
|
|
|
|
82
|
+ if (!is_array($value)) {
|
|
|
|
83
|
+ if (@json_decode($value, true)) {
|
|
|
|
84
|
+ $value = json_decode($value, true);
|
|
|
|
85
|
+ } else {
|
|
|
|
86
|
+ $value = [['email' => $value, 'name' => '']];
|
|
367
|
}
|
87
|
}
|
|
368
|
}
|
88
|
}
|
|
369
|
- foreach ($value as $item){
|
|
|
|
370
|
- if(!Verify::sEmail($item['email'])){
|
|
|
|
371
|
- app()->e([$field.'_verify_error',$item['email']]);
|
89
|
+ foreach ($value as $item) {
|
|
|
|
90
|
+ if (!Verify::sEmail($item['email'])) {
|
|
|
|
91
|
+ app()->e([$field . '_verify_error', $item['email']]);
|
|
372
|
}
|
92
|
}
|
|
373
|
}
|
93
|
}
|
|
374
|
}
|
94
|
}
|
|
375
|
};
|
95
|
};
|
|
376
|
|
96
|
|
|
377
|
$formData = Verify::checks([
|
97
|
$formData = Verify::checks([
|
|
378
|
- 'nickname|'.__('nickname') => ['max'=>50],
|
|
|
|
379
|
- 'subject|'.__('subject') => ['required','max'=>500],
|
|
|
|
380
|
- 'body|'.__('body_email') => ['required'],
|
|
|
|
381
|
- 'tos|'.__('to_email') => ['required',$yzemail],
|
|
|
|
382
|
- 'cc|'.__('to_cc') => [$yzemail],
|
|
|
|
383
|
- 'bcc|'.__('to_bcc') => [$yzemail],
|
|
|
|
384
|
- 'priority|'.__('priority_email') => ['in'=>[1,3,5]],
|
98
|
+ 'nickname|' . __('nickname') => ['max' => 50],
|
|
|
|
99
|
+ 'subject|' . __('subject') => ['required', 'max' => 500],
|
|
|
|
100
|
+ 'body|' . __('body_email') => ['required'],
|
|
|
|
101
|
+ 'tos|' . __('to_email') => ['required', $yzemail],
|
|
|
|
102
|
+ 'cc|' . __('to_cc') => [$yzemail],
|
|
|
|
103
|
+ 'bcc|' . __('to_bcc') => [$yzemail],
|
|
|
|
104
|
+ 'priority|' . __('priority_email') => ['in' => [1, 3, 5]],
|
|
385
|
// 'attachment|'.__('files_email') => [
|
105
|
// 'attachment|'.__('files_email') => [
|
|
386
|
// 'file'=>[
|
106
|
// 'file'=>[
|
|
387
|
// 'ext' => [],
|
107
|
// 'ext' => [],
|
|
@@ -389,166 +109,164 @@ class Home extends Base { |
|
@@ -389,166 +109,164 @@ class Home extends Base { |
|
389
|
// 'mine' => []
|
109
|
// 'mine' => []
|
|
390
|
// ]
|
110
|
// ]
|
|
391
|
// ],
|
111
|
// ],
|
|
392
|
- 'receipt|'.__('receipt_email') => []
|
|
|
|
393
|
- ],[
|
112
|
+ 'receipt|' . __('receipt_email') => []
|
|
|
|
113
|
+ ], [
|
|
394
|
|
114
|
|
|
395
|
]);
|
115
|
]);
|
|
396
|
|
116
|
|
|
397
|
|
117
|
|
|
398
|
$sendData = [];
|
118
|
$sendData = [];
|
|
399
|
- $sendData['email'] = $email['email'];
|
|
|
|
400
|
- $sendData['nickname'] = $formData['nickname']??'';
|
|
|
|
401
|
- $sendData['tos'] = $formData['tos'];
|
|
|
|
402
|
- if(count($sendData['tos'])>100){
|
|
|
|
403
|
- app()->e(['tos_number_error',100]);
|
119
|
+ $sendData['email'] = $email['email'];
|
|
|
|
120
|
+ $sendData['nickname'] = $formData['nickname'] ?? '';
|
|
|
|
121
|
+ $sendData['tos'] = $formData['tos'];
|
|
|
|
122
|
+ if (count($sendData['tos']) > 100) {
|
|
|
|
123
|
+ app()->e(['tos_number_error', 100]);
|
|
404
|
}
|
124
|
}
|
|
405
|
// 抄送
|
125
|
// 抄送
|
|
406
|
$sendData['cc'] = [];
|
126
|
$sendData['cc'] = [];
|
|
407
|
- if(($formData['isCc']??0) && !empty($formData['cc'])){
|
|
|
|
408
|
- $sendData['cc'] = $formData['cc'];
|
127
|
+ if (($formData['isCc'] ?? 0) && !empty($formData['cc'])) {
|
|
|
|
128
|
+ $sendData['cc'] = $formData['cc'];
|
|
409
|
}
|
129
|
}
|
|
410
|
- if(count($sendData['cc'])>10){
|
|
|
|
411
|
- app()->e(['cc_number_error',10]);
|
130
|
+ if (count($sendData['cc']) > 10) {
|
|
|
|
131
|
+ app()->e(['cc_number_error', 10]);
|
|
412
|
}
|
132
|
}
|
|
413
|
// 密送
|
133
|
// 密送
|
|
414
|
$sendData['bcc'] = [];
|
134
|
$sendData['bcc'] = [];
|
|
415
|
- if(($formData['isBcc']??0) && !empty($formData['bcc'])){
|
|
|
|
416
|
- $sendData['bcc'] = $formData['bcc'];
|
135
|
+ if (($formData['isBcc'] ?? 0) && !empty($formData['bcc'])) {
|
|
|
|
136
|
+ $sendData['bcc'] = $formData['bcc'];
|
|
417
|
}
|
137
|
}
|
|
418
|
|
138
|
|
|
419
|
// 添加自定义头信息 预热邮件
|
139
|
// 添加自定义头信息 预热邮件
|
|
420
|
- if(!empty($formData['aicc-hot'])){
|
140
|
+ if (!empty($formData['aicc-hot'])) {
|
|
421
|
$sendData['mail-header'] = [
|
141
|
$sendData['mail-header'] = [
|
|
422
|
- 'Aicc-Hot-Mail' => 'hot' // 预热邮件
|
142
|
+ 'Aicc-Hot-Mail' => 'hot' // 预热邮件
|
|
423
|
];
|
143
|
];
|
|
424
|
}
|
144
|
}
|
|
425
|
|
145
|
|
|
426
|
- if(count($sendData['bcc'])>10){
|
|
|
|
427
|
- app()->e(['bcc_number_error',10]);
|
146
|
+ if (count($sendData['bcc']) > 10) {
|
|
|
|
147
|
+ app()->e(['bcc_number_error', 10]);
|
|
428
|
}
|
148
|
}
|
|
429
|
$sendData['reply_to'] = [];//回复到那个邮件
|
149
|
$sendData['reply_to'] = [];//回复到那个邮件
|
|
430
|
//Attachments 附件 上传的
|
150
|
//Attachments 附件 上传的
|
|
431
|
$sendData['attachment'] = [];
|
151
|
$sendData['attachment'] = [];
|
|
432
|
// 这个是直接上传文件
|
152
|
// 这个是直接上传文件
|
|
433
|
$attachment = app()->file('attachment');
|
153
|
$attachment = app()->file('attachment');
|
|
434
|
- if($attachment){
|
|
|
|
435
|
- foreach ($attachment as $file){
|
|
|
|
436
|
- if($file->move()){
|
154
|
+ if ($attachment) {
|
|
|
|
155
|
+ foreach ($attachment as $file) {
|
|
|
|
156
|
+ if ($file->move()) {
|
|
437
|
$sendData['attachment'][] = [
|
157
|
$sendData['attachment'][] = [
|
|
438
|
- 'name' => $file->name,
|
|
|
|
439
|
- 'filename' => $file->name,
|
|
|
|
440
|
- 'signName' => $file->saveName,
|
|
|
|
441
|
- 'path' => $file->savePath.$file->saveName
|
158
|
+ 'name' => $file->name,
|
|
|
|
159
|
+ 'filename' => $file->name,
|
|
|
|
160
|
+ 'signName' => $file->saveName,
|
|
|
|
161
|
+ 'path' => $file->savePath . $file->saveName
|
|
442
|
];
|
162
|
];
|
|
443
|
- }else{
|
|
|
|
444
|
- app()->e(['attachment_upload_error',$file->name]);
|
163
|
+ } else {
|
|
|
|
164
|
+ app()->e(['attachment_upload_error', $file->name]);
|
|
445
|
}
|
165
|
}
|
|
446
|
}
|
166
|
}
|
|
447
|
}
|
167
|
}
|
|
448
|
// 这个是通过了上传接口上传的文件
|
168
|
// 这个是通过了上传接口上传的文件
|
|
449
|
$attachment = app()->request('attachmentapi');
|
169
|
$attachment = app()->request('attachmentapi');
|
|
450
|
- if($attachment){
|
|
|
|
451
|
- foreach ($attachment as $file){
|
|
|
|
452
|
- $file = json_decode($file,true);
|
|
|
|
453
|
- if(empty($file['data']['saveName'])|| !is_file(PUBLIC_PATH.$file['data']['saveName'])){
|
|
|
|
454
|
- app()->e('附件('.$file['data']['name'].")异常");
|
170
|
+ if ($attachment) {
|
|
|
|
171
|
+ foreach ($attachment as $file) {
|
|
|
|
172
|
+ $file = json_decode($file, true);
|
|
|
|
173
|
+ if (empty($file['data']['saveName']) || !is_file(PUBLIC_PATH . $file['data']['saveName'])) {
|
|
|
|
174
|
+ app()->e('附件(' . $file['data']['name'] . ")异常");
|
|
455
|
}
|
175
|
}
|
|
456
|
$sendData['attachment'][] = [
|
176
|
$sendData['attachment'][] = [
|
|
457
|
- 'name' => $file['data']['name'],
|
|
|
|
458
|
- 'filename' => $file['data']['name'],
|
|
|
|
459
|
- 'signName' => $file['data']['saveName'],
|
|
|
|
460
|
- 'path' => PUBLIC_PATH.$file['data']['saveName']
|
177
|
+ 'name' => $file['data']['name'],
|
|
|
|
178
|
+ 'filename' => $file['data']['name'],
|
|
|
|
179
|
+ 'signName' => $file['data']['saveName'],
|
|
|
|
180
|
+ 'path' => PUBLIC_PATH . $file['data']['saveName']
|
|
461
|
];
|
181
|
];
|
|
462
|
}
|
182
|
}
|
|
463
|
}
|
183
|
}
|
|
464
|
|
184
|
|
|
465
|
// 远程路径,云文件
|
185
|
// 远程路径,云文件
|
|
466
|
$attachmentUrl = app()->request('attachmentUrl');
|
186
|
$attachmentUrl = app()->request('attachmentUrl');
|
|
467
|
- if(is_array($attachmentUrl)){
|
|
|
|
468
|
- foreach ($attachmentUrl as $file){
|
|
|
|
469
|
- $file = is_array($file) ? $file : json_decode($file,true);
|
|
|
|
470
|
- if(!empty($file['url']) && !empty($file['name'])){
|
|
|
|
471
|
- $file = new UploadFile($file['name'],$file['url']);
|
|
|
|
472
|
- if($file->move()){
|
187
|
+ if (is_array($attachmentUrl)) {
|
|
|
|
188
|
+ foreach ($attachmentUrl as $file) {
|
|
|
|
189
|
+ $file = is_array($file) ? $file : json_decode($file, true);
|
|
|
|
190
|
+ if (!empty($file['url']) && !empty($file['name'])) {
|
|
|
|
191
|
+ $file = new UploadFile($file['name'], $file['url']);
|
|
|
|
192
|
+ if ($file->move()) {
|
|
473
|
$sendData['attachment'][] = [
|
193
|
$sendData['attachment'][] = [
|
|
474
|
- 'name' => $file->name,
|
|
|
|
475
|
- 'filename' => $file->name,
|
|
|
|
476
|
- 'signName' => $file->saveName,
|
|
|
|
477
|
- 'path' => $file->savePath.$file->saveName
|
194
|
+ 'name' => $file->name,
|
|
|
|
195
|
+ 'filename' => $file->name,
|
|
|
|
196
|
+ 'signName' => $file->saveName,
|
|
|
|
197
|
+ 'path' => $file->savePath . $file->saveName
|
|
478
|
];
|
198
|
];
|
|
479
|
- }else{
|
|
|
|
480
|
- app()->e(['attachment_upload_error',$file->name]);
|
199
|
+ } else {
|
|
|
|
200
|
+ app()->e(['attachment_upload_error', $file->name]);
|
|
481
|
}
|
201
|
}
|
|
482
|
}
|
202
|
}
|
|
483
|
|
203
|
|
|
484
|
}
|
204
|
}
|
|
485
|
}
|
205
|
}
|
|
486
|
$sendData['receipt'] = empty($formData['receipt']) ? '' : 1;// 回执,阅读后收回执的邮箱
|
206
|
$sendData['receipt'] = empty($formData['receipt']) ? '' : 1;// 回执,阅读后收回执的邮箱
|
|
487
|
- $sendData['priority'] = $formData['priority']??3;// 是否紧急邮件
|
207
|
+ $sendData['priority'] = $formData['priority'] ?? 3;// 是否紧急邮件
|
|
488
|
$sendData['subject'] = $formData['subject'];// //Content 主题,标题
|
208
|
$sendData['subject'] = $formData['subject'];// //Content 主题,标题
|
|
489
|
// 删除script标记
|
209
|
// 删除script标记
|
|
490
|
- $sendData['body'] = strip_tags_content($formData['body'],'<script>',true);
|
210
|
+ $sendData['body'] = strip_tags_content($formData['body'], '<script>', true);
|
|
491
|
// 下划线
|
211
|
// 下划线
|
|
492
|
- $sendData['body'] = str_replace('class="sensitive-word"',' ',$sendData['body']);
|
|
|
|
493
|
- $sendData['body'] = str_replace('style="text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: red;"',' ',$sendData['body']);
|
212
|
+ $sendData['body'] = str_replace('class="sensitive-word"', ' ', $sendData['body']);
|
|
|
|
213
|
+ $sendData['body'] = str_replace('style="text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: red;"', ' ', $sendData['body']);
|
|
494
|
|
214
|
|
|
495
|
// 不重要的信息
|
215
|
// 不重要的信息
|
|
496
|
- $sendData['jobName'] = $formData['jobName']??'';//任务标题
|
|
|
|
497
|
- $sendData['massSuit'] = $formData['massSuit']??0;// 是否是群发单显
|
216
|
+ $sendData['jobName'] = $formData['jobName'] ?? '';//任务标题
|
|
|
|
217
|
+ $sendData['massSuit'] = $formData['massSuit'] ?? 0;// 是否是群发单显
|
|
498
|
|
218
|
|
|
499
|
// 定时发送时间
|
219
|
// 定时发送时间
|
|
500
|
- $timer = app()->request('timerValue',0);
|
|
|
|
501
|
- if(is_numeric($timer) && $timer){
|
|
|
|
502
|
- $timer = time()+$timer;
|
|
|
|
503
|
- }else if (is_string($timer)){
|
220
|
+ $timer = app()->request('timerValue', 0);
|
|
|
|
221
|
+ if (is_numeric($timer) && $timer) {
|
|
|
|
222
|
+ $timer = time() + $timer;
|
|
|
|
223
|
+ } else if (is_string($timer)) {
|
|
504
|
$timer = strtotime($timer);
|
224
|
$timer = strtotime($timer);
|
|
505
|
- }else{
|
225
|
+ } else {
|
|
506
|
$timer = 0;
|
226
|
$timer = 0;
|
|
507
|
}
|
227
|
}
|
|
508
|
// 是否存草稿
|
228
|
// 是否存草稿
|
|
509
|
- if(app()->request('saveType')=='draft'){
|
229
|
+ if (app()->request('saveType') == 'draft') {
|
|
510
|
// 保存
|
230
|
// 保存
|
|
511
|
- $draftid = listsSql::saveDraft($sendData,$email,app()->request('draft_id',0,'intval'));
|
231
|
+ $draftid = listsSql::saveDraft($sendData, $email, app()->request('draft_id', 0, 'intval'));
|
|
512
|
// 保存失败
|
232
|
// 保存失败
|
|
513
|
- if($draftid){
|
|
|
|
514
|
- app()->_json(['draft_id'=>$draftid]);
|
233
|
+ if ($draftid) {
|
|
|
|
234
|
+ app()->_json(['draft_id' => $draftid]);
|
|
515
|
}
|
235
|
}
|
|
516
|
app()->e('save_draft_error');
|
236
|
app()->e('save_draft_error');
|
|
517
|
|
237
|
|
|
518
|
- }
|
|
|
|
519
|
- // 定时发送 或者是单条发送
|
|
|
|
520
|
- else if((app()->request('timer') && $timer > time()) || $sendData['massSuit']){
|
238
|
+ } // 定时发送 或者是单条发送
|
|
|
|
239
|
+ else if ((app()->request('timer') && $timer > time()) || $sendData['massSuit']) {
|
|
521
|
|
240
|
|
|
522
|
- if($sendData['massSuit']){
|
241
|
+ if ($sendData['massSuit']) {
|
|
523
|
// 每次发送间隔的时间
|
242
|
// 每次发送间隔的时间
|
|
524
|
- $sendData['masssuit_interval_send'] = app()->request('masssuit_interval_send');
|
|
|
|
525
|
- $sendData['masssuit_interval_send']['start'] = intval($sendData['masssuit_interval_send']['start']??0);
|
|
|
|
526
|
- $sendData['masssuit_interval_send']['end'] = intval($sendData['masssuit_interval_send']['end']??1);
|
243
|
+ $sendData['masssuit_interval_send'] = app()->request('masssuit_interval_send');
|
|
|
|
244
|
+ $sendData['masssuit_interval_send']['start'] = intval($sendData['masssuit_interval_send']['start'] ?? 0);
|
|
|
|
245
|
+ $sendData['masssuit_interval_send']['end'] = intval($sendData['masssuit_interval_send']['end'] ?? 1);
|
|
527
|
}
|
246
|
}
|
|
528
|
|
247
|
|
|
529
|
|
248
|
|
|
530
|
// 插入任务
|
249
|
// 插入任务
|
|
531
|
- $job_id = db()->insert(sendJobsSql::$table,[
|
|
|
|
532
|
- 'email_id' => $email['id'],
|
|
|
|
533
|
- 'maildata' => $sendData,
|
|
|
|
534
|
- 'title' => $sendData['jobName'] ? : $sendData['subject'],
|
|
|
|
535
|
- 'total' => count($sendData['tos']),
|
|
|
|
536
|
- 'send_time' => $timer?:time()
|
250
|
+ $job_id = db()->insert(sendJobsSql::$table, [
|
|
|
|
251
|
+ 'email_id' => $email['id'],
|
|
|
|
252
|
+ 'maildata' => $sendData,
|
|
|
|
253
|
+ 'title' => $sendData['jobName'] ?: $sendData['subject'],
|
|
|
|
254
|
+ 'total' => count($sendData['tos']),
|
|
|
|
255
|
+ 'send_time' => $timer ?: time()
|
|
537
|
]);
|
256
|
]);
|
|
538
|
- if($job_id){
|
257
|
+ if ($job_id) {
|
|
539
|
// 返回任务id
|
258
|
// 返回任务id
|
|
540
|
- app()->_json(['job_id'=>$job_id]);
|
259
|
+ app()->_json(['job_id' => $job_id]);
|
|
541
|
}
|
260
|
}
|
|
542
|
|
261
|
|
|
543
|
app()->e('send_timer_job_error');
|
262
|
app()->e('send_timer_job_error');
|
|
544
|
- }
|
|
|
|
545
|
- else{
|
263
|
+ } else {
|
|
546
|
// 立即发送
|
264
|
// 立即发送
|
|
547
|
- $email['hot_email'] = db()->cache(86400,false)->count("select count(*) from `hot_mail` where ".dbWhere(['email'=>$email['email']]));
|
265
|
+ $email['hot_email'] = db()->cache(86400, false)->count("select count(*) from `hot_mail` where " . dbWhere(['email' => $email['email']]));
|
|
548
|
$email['not_proxy'] = app()->request('not_proxy');//是否要代理
|
266
|
$email['not_proxy'] = app()->request('not_proxy');//是否要代理
|
|
549
|
- $result = MailFun::sendEmail($sendData,$email);
|
|
|
|
550
|
- if($result[0]){
|
|
|
|
551
|
- app()->_json(['messageId' => $result[1]]);
|
267
|
+ $result = MailFun::sendEmail($sendData, $email);
|
|
|
|
268
|
+ if ($result[0]) {
|
|
|
|
269
|
+ app()->_json(['messageId' => $result[1]]);
|
|
552
|
}
|
270
|
}
|
|
553
|
// 错误
|
271
|
// 错误
|
|
554
|
app()->e($result[1]);
|
272
|
app()->e($result[1]);
|
|
@@ -562,54 +280,55 @@ class Home extends Base { |
|
@@ -562,54 +280,55 @@ class Home extends Base { |
|
562
|
* @author:dc
|
280
|
* @author:dc
|
|
563
|
* @time 2023/3/10 10:38
|
281
|
* @time 2023/3/10 10:38
|
|
564
|
*/
|
282
|
*/
|
|
565
|
- public function sync(){
|
283
|
+ public function sync()
|
|
|
|
284
|
+ {
|
|
566
|
|
285
|
|
|
567
|
$emails = web_request_emails();
|
286
|
$emails = web_request_emails();
|
|
568
|
$sync_type = app()->request('sync_type');
|
287
|
$sync_type = app()->request('sync_type');
|
|
569
|
- if(empty($emails)){
|
288
|
+ if (empty($emails)) {
|
|
570
|
app()->e('sync_request_param_error');
|
289
|
app()->e('sync_request_param_error');
|
|
571
|
- }else{
|
290
|
+ } else {
|
|
572
|
// 查询id
|
291
|
// 查询id
|
|
573
|
- if(count($emails)===1){
|
292
|
+ if (count($emails) === 1) {
|
|
574
|
$emails = $emails[0];
|
293
|
$emails = $emails[0];
|
|
575
|
}
|
294
|
}
|
|
576
|
- $datas = db()->cache(3600)->all(emailSql::getValues(['email'=>$emails],'`id`,`email`,`pwd_error`'));
|
|
|
|
577
|
- foreach ($datas as $k=>$v){
|
|
|
|
578
|
- if(!$v['pwd_error']){
|
|
|
|
579
|
- if(app()->requestHas('blacklist')){
|
295
|
+ $datas = db()->cache(3600)->all(emailSql::getValues(['email' => $emails], '`id`,`email`,`pwd_error`'));
|
|
|
|
296
|
+ foreach ($datas as $k => $v) {
|
|
|
|
297
|
+ if (!$v['pwd_error']) {
|
|
|
|
298
|
+ if (app()->requestHas('blacklist')) {
|
|
580
|
$blacklist = app()->request('blacklist');
|
299
|
$blacklist = app()->request('blacklist');
|
|
581
|
- if(is_array($blacklist)){
|
300
|
+ if (is_array($blacklist)) {
|
|
582
|
$blacklist = [
|
301
|
$blacklist = [
|
|
583
|
- 'emails' => $blacklist['emails']??[],
|
|
|
|
584
|
- 'domain' => $blacklist['domain']??[],
|
302
|
+ 'emails' => $blacklist['emails'] ?? [],
|
|
|
|
303
|
+ 'domain' => $blacklist['domain'] ?? [],
|
|
585
|
];
|
304
|
];
|
|
586
|
// 黑名单,7天过期时间
|
305
|
// 黑名单,7天过期时间
|
|
587
|
- redis()->set('blacklist:'.$v['id'],$blacklist,86400*7);
|
306
|
+ redis()->set('blacklist:' . $v['id'], $blacklist, 86400 * 7);
|
|
588
|
}
|
307
|
}
|
|
589
|
// 删除
|
308
|
// 删除
|
|
590
|
- if(!$blacklist||(empty($blacklist['emails'])&&empty($blacklist['domain']))){
|
|
|
|
591
|
- redis()->delete('blacklist:'.$v['id']);
|
309
|
+ if (!$blacklist || (empty($blacklist['emails']) && empty($blacklist['domain']))) {
|
|
|
|
310
|
+ redis()->delete('blacklist:' . $v['id']);
|
|
592
|
}
|
311
|
}
|
|
593
|
|
312
|
|
|
594
|
}
|
313
|
}
|
|
595
|
$source = app()->request('source');
|
314
|
$source = app()->request('source');
|
|
596
|
|
315
|
|
|
597
|
// 是否立即同步
|
316
|
// 是否立即同步
|
|
598
|
- if($sync_type == 'immediately'){
|
|
|
|
599
|
- try{
|
|
|
|
600
|
- if(redis()->add('sync_immediately:'.$v['id'],1,10)){
|
317
|
+ if ($sync_type == 'immediately') {
|
|
|
|
318
|
+ try {
|
|
|
|
319
|
+ if (redis()->add('sync_immediately:' . $v['id'], 1, 10)) {
|
|
601
|
(new SyncMail($v['id']))->isUidAfter()->sync();
|
320
|
(new SyncMail($v['id']))->isUidAfter()->sync();
|
|
602
|
}
|
321
|
}
|
|
603
|
- }catch (\Throwable $e){
|
322
|
+ } catch (\Throwable $e) {
|
|
604
|
logs($e->getTraceAsString());
|
323
|
logs($e->getTraceAsString());
|
|
605
|
}
|
324
|
}
|
|
606
|
|
325
|
|
|
607
|
- }else{
|
|
|
|
608
|
- redis()->rPush('sync_email_lists'.($source==1?'_my':''), $v['id']);
|
326
|
+ } else {
|
|
|
|
327
|
+ redis()->rPush('sync_email_lists' . ($source == 1 ? '_my' : ''), $v['id']);
|
|
609
|
}
|
328
|
}
|
|
610
|
|
329
|
|
|
611
|
}
|
330
|
}
|
|
612
|
- $datas[$k]['have_new'] = redis()->getDel('have_new_mail_'.$v['id']);
|
331
|
+ $datas[$k]['have_new'] = redis()->getDel('have_new_mail_' . $v['id']);
|
|
613
|
|
332
|
|
|
614
|
// 计算
|
333
|
// 计算
|
|
615
|
// $folders = db()->all(folderSql::all($v['id'],'`id`'));
|
334
|
// $folders = db()->all(folderSql::all($v['id'],'`id`'));
|
|
@@ -638,7 +357,8 @@ class Home extends Base { |
|
@@ -638,7 +357,8 @@ class Home extends Base { |
|
638
|
* @author:dc
|
357
|
* @author:dc
|
|
639
|
* @time 2023/3/17 16:15
|
358
|
* @time 2023/3/17 16:15
|
|
640
|
*/
|
359
|
*/
|
|
641
|
- public function seen_2_unseen(){
|
360
|
+ public function seen_2_unseen()
|
|
|
|
361
|
+ {
|
|
642
|
$this->setFlags('seen');
|
362
|
$this->setFlags('seen');
|
|
643
|
}
|
363
|
}
|
|
644
|
|
364
|
|
|
@@ -648,7 +368,8 @@ class Home extends Base { |
|
@@ -648,7 +368,8 @@ class Home extends Base { |
|
648
|
* @author:dc
|
368
|
* @author:dc
|
|
649
|
* @time 2023/4/10 16:30
|
369
|
* @time 2023/4/10 16:30
|
|
650
|
*/
|
370
|
*/
|
|
651
|
- public function answered_2_unanswered(){
|
371
|
+ public function answered_2_unanswered()
|
|
|
|
372
|
+ {
|
|
652
|
$this->setFlags('answered');
|
373
|
$this->setFlags('answered');
|
|
653
|
}
|
374
|
}
|
|
654
|
|
375
|
|
|
@@ -658,33 +379,32 @@ class Home extends Base { |
|
@@ -658,33 +379,32 @@ class Home extends Base { |
|
658
|
* @author:dc
|
379
|
* @author:dc
|
|
659
|
* @time 2024/6/21 16:35
|
380
|
* @time 2024/6/21 16:35
|
|
660
|
*/
|
381
|
*/
|
|
661
|
- public function star_2_unstar(){
|
|
|
|
662
|
- logs("操作星标邮件 ".print_r(app()->request(),1));
|
382
|
+ public function star_2_unstar()
|
|
|
|
383
|
+ {
|
|
|
|
384
|
+ logs("操作星标邮件 " . print_r(app()->request(), 1));
|
|
663
|
$this->setFlags('flagged');
|
385
|
$this->setFlags('flagged');
|
|
664
|
}
|
386
|
}
|
|
665
|
|
387
|
|
|
666
|
|
388
|
|
|
667
|
-
|
|
|
|
668
|
-
|
|
|
|
669
|
-
|
|
|
|
670
|
/**
|
389
|
/**
|
|
671
|
* 邮件移动
|
390
|
* 邮件移动
|
|
672
|
* @author:dc
|
391
|
* @author:dc
|
|
673
|
* @time 2023/3/21 11:41
|
392
|
* @time 2023/3/21 11:41
|
|
674
|
*/
|
393
|
*/
|
|
675
|
- public function move(){
|
|
|
|
676
|
- $this->moveCopy(function (Mail $mailInstance,$uid,$origin_folder,$to_origin_folder){
|
394
|
+ public function move()
|
|
|
|
395
|
+ {
|
|
|
|
396
|
+ $this->moveCopy(function (Mail $mailInstance, $uid, $origin_folder, $to_origin_folder) {
|
|
677
|
// try {
|
397
|
// try {
|
|
678
|
// return $mailInstance->move($uid,$origin_folder,$to_origin_folder);
|
398
|
// return $mailInstance->move($uid,$origin_folder,$to_origin_folder);
|
|
679
|
// }catch (\Throwable $e){
|
399
|
// }catch (\Throwable $e){
|
|
680
|
// if(app()->request('move_err_copy',1)){
|
400
|
// if(app()->request('move_err_copy',1)){
|
|
681
|
// 复制成功
|
401
|
// 复制成功
|
|
682
|
try {
|
402
|
try {
|
|
683
|
- if($mailInstance->copy($uid,$origin_folder,$to_origin_folder)){
|
|
|
|
684
|
- return $mailInstance->deleted($uid,$origin_folder);
|
403
|
+ if ($mailInstance->copy($uid, $origin_folder, $to_origin_folder)) {
|
|
|
|
404
|
+ return $mailInstance->deleted($uid, $origin_folder);
|
|
685
|
}
|
405
|
}
|
|
686
|
- }catch (\Throwable $e){
|
|
|
|
687
|
- logs('移动失败:'.$e->getMessage());
|
406
|
+ } catch (\Throwable $e) {
|
|
|
|
407
|
+ logs('移动失败:' . $e->getMessage());
|
|
688
|
return false;
|
408
|
return false;
|
|
689
|
}
|
409
|
}
|
|
690
|
|
410
|
|
|
@@ -696,89 +416,88 @@ class Home extends Base { |
|
@@ -696,89 +416,88 @@ class Home extends Base { |
|
696
|
}
|
416
|
}
|
|
697
|
|
417
|
|
|
698
|
|
418
|
|
|
699
|
- private function moveCopy(\Closure $call){
|
419
|
+ private function moveCopy(\Closure $call)
|
|
|
|
420
|
+ {
|
|
700
|
$emails = $this->getEmails();
|
421
|
$emails = $this->getEmails();
|
|
701
|
|
422
|
|
|
702
|
$mail_ids = app()->requestArr('mail_ids');
|
423
|
$mail_ids = app()->requestArr('mail_ids');
|
|
703
|
- if(!($mail_ids && is_array($mail_ids))){
|
424
|
+ if (!($mail_ids && is_array($mail_ids))) {
|
|
704
|
app()->e('param_request_error');
|
425
|
app()->e('param_request_error');
|
|
705
|
}
|
426
|
}
|
|
706
|
- foreach ($mail_ids as $k=>$id){
|
|
|
|
707
|
- if(!is_numeric($id)){
|
427
|
+ foreach ($mail_ids as $k => $id) {
|
|
|
|
428
|
+ if (!is_numeric($id)) {
|
|
708
|
unset($mail_ids[$k]);
|
429
|
unset($mail_ids[$k]);
|
|
709
|
}
|
430
|
}
|
|
710
|
}
|
431
|
}
|
|
711
|
// 移动到的文件夹
|
432
|
// 移动到的文件夹
|
|
712
|
$to_folder = folderAlias(app()->request('folder'));
|
433
|
$to_folder = folderAlias(app()->request('folder'));
|
|
713
|
- if(empty($to_folder)){
|
434
|
+ if (empty($to_folder)) {
|
|
714
|
app()->e('folder_move_error');
|
435
|
app()->e('folder_move_error');
|
|
715
|
}
|
436
|
}
|
|
716
|
- if($to_folder == '草稿箱'){
|
437
|
+ if ($to_folder == '草稿箱') {
|
|
717
|
app()->e('folder_move_to_draft_error');
|
438
|
app()->e('folder_move_to_draft_error');
|
|
718
|
}
|
439
|
}
|
|
719
|
- if($to_folder == '发件箱'){
|
440
|
+ if ($to_folder == '发件箱') {
|
|
720
|
app()->e('folder_move_to_send_error');
|
441
|
app()->e('folder_move_to_send_error');
|
|
721
|
}
|
442
|
}
|
|
722
|
|
443
|
|
|
723
|
- $data = db()->all(listsSql::all(dbWhere(['id'=>$mail_ids,'email_id'=>array_column($emails,'id')]),'`id`,`uid`,`email_id`,`folder_id`'));
|
|
|
|
724
|
- if($data){
|
444
|
+ $data = listsSql::all(db(), dbWhere(['id' => $mail_ids, 'email_id' => array_column($emails, 'id')]), '`id`,`uid`,`email_id`,`folder_id`');
|
|
|
|
445
|
+ if ($data) {
|
|
725
|
// 查询邮箱
|
446
|
// 查询邮箱
|
|
726
|
- $emails = array_column($emails,null,'id');
|
447
|
+ $emails = array_column($emails, null, 'id');
|
|
727
|
$uids = [];
|
448
|
$uids = [];
|
|
728
|
- foreach ($data as $datum){
|
449
|
+ foreach ($data as $datum) {
|
|
729
|
// 只有草稿箱才没有uid
|
450
|
// 只有草稿箱才没有uid
|
|
730
|
// if($datum['uid']<0){
|
451
|
// if($datum['uid']<0){
|
|
731
|
|
452
|
|
|
732
|
// }
|
453
|
// }
|
|
733
|
|
454
|
|
|
734
|
// 删除
|
455
|
// 删除
|
|
735
|
- if ($to_folder == '回收站'){
|
456
|
+ if ($to_folder == '回收站') {
|
|
736
|
// 删除数据,真实删除
|
457
|
// 删除数据,真实删除
|
|
737
|
- db()->update(listsSql::$table,[
|
|
|
|
738
|
- 'deleted' => 1
|
|
|
|
739
|
- ],dbWhere([
|
|
|
|
740
|
- 'id' => $datum['id']
|
|
|
|
741
|
- ]));
|
458
|
+ listsSql::update(db(), [
|
|
|
|
459
|
+ 'deleted' => 1
|
|
|
|
460
|
+ ], $datum['id']);
|
|
742
|
continue;
|
461
|
continue;
|
|
743
|
}
|
462
|
}
|
|
744
|
|
463
|
|
|
745
|
- if(empty($uids[$datum['email_id']][$datum['folder_id']])){
|
464
|
+ if (empty($uids[$datum['email_id']][$datum['folder_id']])) {
|
|
746
|
$uids[$datum['email_id']][$datum['folder_id']] = [];
|
465
|
$uids[$datum['email_id']][$datum['folder_id']] = [];
|
|
747
|
}
|
466
|
}
|
|
748
|
$uids[$datum['email_id']][$datum['folder_id']][] = [
|
467
|
$uids[$datum['email_id']][$datum['folder_id']][] = [
|
|
749
|
- 'uid' => $datum['uid'],
|
|
|
|
750
|
- 'id' => $datum['id'],
|
468
|
+ 'uid' => $datum['uid'],
|
|
|
|
469
|
+ 'id' => $datum['id'],
|
|
751
|
];
|
470
|
];
|
|
752
|
}
|
471
|
}
|
|
753
|
|
472
|
|
|
754
|
- foreach ($uids as $eid=>$arr){
|
473
|
+ foreach ($uids as $eid => $arr) {
|
|
755
|
// 查询需要移动的文件夹
|
474
|
// 查询需要移动的文件夹
|
|
756
|
- $to_origin_folder = db()->first(folderSql::first(['email_id'=>$eid,'folder'=>$to_folder]));
|
|
|
|
757
|
- if($to_origin_folder){
|
|
|
|
758
|
- foreach ($arr as $fid=>$uid){
|
475
|
+ $to_origin_folder = db()->first(folderSql::first(['email_id' => $eid, 'folder' => $to_folder]));
|
|
|
|
476
|
+ if ($to_origin_folder) {
|
|
|
|
477
|
+ foreach ($arr as $fid => $uid) {
|
|
759
|
// 查询目录
|
478
|
// 查询目录
|
|
760
|
$folder = db()->first(folderSql::first($fid));
|
479
|
$folder = db()->first(folderSql::first($fid));
|
|
761
|
- if($folder){
|
480
|
+ if ($folder) {
|
|
762
|
// 开始远程
|
481
|
// 开始远程
|
|
763
|
- $mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
|
482
|
+ $mailInstance = new Mail($emails[$eid]['email'], base64_decode($emails[$eid]['password']), $emails[$eid]['imap']);
|
|
764
|
|
483
|
|
|
765
|
- if($mailInstance->login()==1){
|
|
|
|
766
|
- $localUids = array_column($uid,'uid');
|
484
|
+ if ($mailInstance->login() == 1) {
|
|
|
|
485
|
+ $localUids = array_column($uid, 'uid');
|
|
767
|
// 检查 远程是否有邮件
|
486
|
// 检查 远程是否有邮件
|
|
768
|
$mailInstance->client->selectFolder($folder['origin_folder']);
|
487
|
$mailInstance->client->selectFolder($folder['origin_folder']);
|
|
769
|
- $originUids = $mailInstance->client->fetch($localUids,'UID',true);
|
488
|
+ $originUids = $mailInstance->client->fetch($localUids, 'UID', true);
|
|
770
|
|
489
|
|
|
771
|
- if($originUids){
|
490
|
+ if ($originUids) {
|
|
772
|
// 进行移动 远程有的邮件
|
491
|
// 进行移动 远程有的邮件
|
|
773
|
- $ret = $call($mailInstance,array_column($originUids,'UID'),$folder['origin_folder'],$to_origin_folder['origin_folder']);
|
|
|
|
774
|
- }else{
|
492
|
+ $ret = $call($mailInstance, array_column($originUids, 'UID'), $folder['origin_folder'], $to_origin_folder['origin_folder']);
|
|
|
|
493
|
+ } else {
|
|
775
|
$ret = true;
|
494
|
$ret = true;
|
|
776
|
}
|
495
|
}
|
|
777
|
|
496
|
|
|
778
|
// TODO:: 这个过程无法保证原子性。没办法
|
497
|
// TODO:: 这个过程无法保证原子性。没办法
|
|
779
|
// 先复制
|
498
|
// 先复制
|
|
780
|
- if($ret){
|
|
|
|
781
|
- $uret = db()->update(listsSql::$table,['deleted'=>1],dbWhere(['id'=>array_column($uid,'id')]));
|
499
|
+ if ($ret) {
|
|
|
|
500
|
+ listsSql::update(db(), ['deleted' => 1], dbWhere(['id' => array_column($uid, 'id')]));
|
|
782
|
}
|
501
|
}
|
|
783
|
|
502
|
|
|
784
|
|
503
|
|
|
@@ -797,7 +516,7 @@ class Home extends Base { |
|
@@ -797,7 +516,7 @@ class Home extends Base { |
|
797
|
|
516
|
|
|
798
|
|
517
|
|
|
799
|
app()->_json([
|
518
|
app()->_json([
|
|
800
|
- 'mail_id' => $mail_ids
|
519
|
+ 'mail_id' => $mail_ids
|
|
801
|
]);
|
520
|
]);
|
|
802
|
}
|
521
|
}
|
|
803
|
|
522
|
|
|
@@ -808,10 +527,11 @@ class Home extends Base { |
|
@@ -808,10 +527,11 @@ class Home extends Base { |
|
808
|
* @author:dc
|
527
|
* @author:dc
|
|
809
|
* @time 2024/3/9 13:50
|
528
|
* @time 2024/3/9 13:50
|
|
810
|
*/
|
529
|
*/
|
|
811
|
- public function copy(){
|
|
|
|
812
|
- $this->moveCopy(function (Mail $mailInstance,$uid,$origin_folder,$to_origin_folder){
|
530
|
+ public function copy()
|
|
|
|
531
|
+ {
|
|
|
|
532
|
+ $this->moveCopy(function (Mail $mailInstance, $uid, $origin_folder, $to_origin_folder) {
|
|
813
|
|
533
|
|
|
814
|
- return $mailInstance->copy($uid,$origin_folder,$to_origin_folder);
|
534
|
+ return $mailInstance->copy($uid, $origin_folder, $to_origin_folder);
|
|
815
|
|
535
|
|
|
816
|
});
|
536
|
});
|
|
817
|
}
|
537
|
}
|
|
@@ -823,11 +543,12 @@ class Home extends Base { |
|
@@ -823,11 +543,12 @@ class Home extends Base { |
|
823
|
* @author:dc
|
543
|
* @author:dc
|
|
824
|
* @time 2024/3/14 14:18
|
544
|
* @time 2024/3/14 14:18
|
|
825
|
*/
|
545
|
*/
|
|
826
|
- public function expunge(){
|
546
|
+ public function expunge()
|
|
|
|
547
|
+ {
|
|
827
|
$email = $this->getEmail();
|
548
|
$email = $this->getEmail();
|
|
828
|
- $mailInstance = new Mail($email['email'],base64_decode($email['password']),$email['imap']);
|
549
|
+ $mailInstance = new Mail($email['email'], base64_decode($email['password']), $email['imap']);
|
|
829
|
|
550
|
|
|
830
|
- if($mailInstance->login()==1 && $mailInstance->expunge()){
|
551
|
+ if ($mailInstance->login() == 1 && $mailInstance->expunge()) {
|
|
831
|
app()->_json([]);
|
552
|
app()->_json([]);
|
|
832
|
}
|
553
|
}
|
|
833
|
|
554
|
|
|
@@ -835,8 +556,6 @@ class Home extends Base { |
|
@@ -835,8 +556,6 @@ class Home extends Base { |
|
835
|
}
|
556
|
}
|
|
836
|
|
557
|
|
|
837
|
|
558
|
|
|
838
|
-
|
|
|
|
839
|
-
|
|
|
|
840
|
/**
|
559
|
/**
|
|
841
|
* 远程标签
|
560
|
* 远程标签
|
|
842
|
* @param $d
|
561
|
* @param $d
|
|
@@ -844,118 +563,113 @@ class Home extends Base { |
|
@@ -844,118 +563,113 @@ class Home extends Base { |
|
844
|
* @author:dc
|
563
|
* @author:dc
|
|
845
|
* @time 2023/3/21 14:28
|
564
|
* @time 2023/3/21 14:28
|
|
846
|
*/
|
565
|
*/
|
|
847
|
- private function setFlags($d){
|
566
|
+ private function setFlags($d)
|
|
|
|
567
|
+ {
|
|
848
|
$emails = $this->getEmails();
|
568
|
$emails = $this->getEmails();
|
|
849
|
|
569
|
|
|
850
|
$mail_ids = app()->request('mail_ids');
|
570
|
$mail_ids = app()->request('mail_ids');
|
|
851
|
|
571
|
|
|
852
|
// 全部标记
|
572
|
// 全部标记
|
|
853
|
- if(!$mail_ids){
|
573
|
+ if (!$mail_ids) {
|
|
854
|
app()->e('标记失败');
|
574
|
app()->e('标记失败');
|
|
855
|
- $folder = app()->request('folder','收件箱','folderAlias');
|
575
|
+ $folder = app()->request('folder', '收件箱', 'folderAlias');
|
|
856
|
// 查询 当前的 文件夹 如果有选中文件夹 就 查询出 选中文件夹的id
|
576
|
// 查询 当前的 文件夹 如果有选中文件夹 就 查询出 选中文件夹的id
|
|
857
|
- $fids = db()->all(folderSql::all(array_column($emails,'id'),'`id`,`folder`'));
|
|
|
|
858
|
- foreach ($fids as $fk=>$fid){
|
|
|
|
859
|
- if($fid['folder'] != $folder){
|
577
|
+ $fids = db()->all(folderSql::all(array_column($emails, 'id'), '`id`,`folder`'));
|
|
|
|
578
|
+ foreach ($fids as $fk => $fid) {
|
|
|
|
579
|
+ if ($fid['folder'] != $folder) {
|
|
860
|
unset($fids[$fk]);
|
580
|
unset($fids[$fk]);
|
|
861
|
}
|
581
|
}
|
|
862
|
}
|
582
|
}
|
|
863
|
- if($fids){
|
583
|
+ if ($fids) {
|
|
864
|
// 查询要标记的 邮件id
|
584
|
// 查询要标记的 邮件id
|
|
865
|
- $sql = listsSql::all(dbWhere(['folder_id'=>array_column($fids,'id'),'seen'=>0]),'`id`');
|
|
|
|
866
|
- $mail_ids = db()->all($sql);
|
|
|
|
867
|
-// $mail_ids2 = db()->all(str_replace('from `lists` where','from `lists_hot` where',$sql));
|
|
|
|
868
|
-// $mail_ids = array_merge($mail_ids,$mail_ids2);
|
|
|
|
869
|
- $mail_ids = array_column($mail_ids,'id');
|
585
|
+ $mail_ids = listsSql::all(db(), dbWhere(['folder_id' => array_column($fids, 'id'), 'seen' => 0]), '`id`');
|
|
|
|
586
|
+ $mail_ids = array_column($mail_ids, 'id');
|
|
870
|
}
|
587
|
}
|
|
871
|
|
588
|
|
|
872
|
}
|
589
|
}
|
|
873
|
|
590
|
|
|
874
|
- if($mail_ids){
|
|
|
|
875
|
- $mail_ids = is_array($mail_ids) ? $mail_ids : explode(',',$mail_ids);
|
591
|
+ if ($mail_ids) {
|
|
|
|
592
|
+ $mail_ids = is_array($mail_ids) ? $mail_ids : explode(',', $mail_ids);
|
|
876
|
}
|
593
|
}
|
|
877
|
|
594
|
|
|
878
|
- if(!($mail_ids && is_array($mail_ids))){
|
595
|
+ if (!($mail_ids && is_array($mail_ids))) {
|
|
879
|
app()->e('param_request_error');
|
596
|
app()->e('param_request_error');
|
|
880
|
}
|
597
|
}
|
|
881
|
- foreach ($mail_ids as $k=>$id){
|
|
|
|
882
|
- if(!is_numeric($id)){
|
598
|
+ foreach ($mail_ids as $k => $id) {
|
|
|
|
599
|
+ if (!is_numeric($id)) {
|
|
883
|
unset($mail_ids[$k]);
|
600
|
unset($mail_ids[$k]);
|
|
884
|
}
|
601
|
}
|
|
885
|
}
|
602
|
}
|
|
886
|
// 已读或未读
|
603
|
// 已读或未读
|
|
887
|
- $fv = (int) app()->request($d);
|
604
|
+ $fv = (int)app()->request($d);
|
|
888
|
$fv = $fv ? 1 : 0;
|
605
|
$fv = $fv ? 1 : 0;
|
|
889
|
|
606
|
|
|
890
|
// if(app()->request('source')==2){
|
607
|
// if(app()->request('source')==2){
|
|
891
|
- $ids = es('email_lists_branch_'.app()->request('postid','','intval'))
|
|
|
|
892
|
- ->search([
|
|
|
|
893
|
- "_source" => ["uuid"],
|
|
|
|
894
|
- 'query'=>[
|
|
|
|
895
|
- 'bool'=>[
|
|
|
|
896
|
- 'must'=>[
|
|
|
|
897
|
- ['terms'=>['uuid'=>$mail_ids]]
|
|
|
|
898
|
- ]
|
608
|
+ $ids = es('email_lists_branch_' . app()->request('postid', '', 'intval'))
|
|
|
|
609
|
+ ->search([
|
|
|
|
610
|
+ "_source" => ["uuid"],
|
|
|
|
611
|
+ 'query' => [
|
|
|
|
612
|
+ 'bool' => [
|
|
|
|
613
|
+ 'must' => [
|
|
|
|
614
|
+ ['terms' => ['uuid' => $mail_ids]]
|
|
899
|
]
|
615
|
]
|
|
900
|
]
|
616
|
]
|
|
901
|
- ],0,1000);
|
|
|
|
902
|
- $mail_ids = [];
|
|
|
|
903
|
- foreach ($ids['hits']['hits']??[] as $item){
|
|
|
|
904
|
- $mail_ids[] = $item['_source']['uuid'];
|
|
|
|
905
|
- }
|
617
|
+ ]
|
|
|
|
618
|
+ ], 0, 1000);
|
|
|
|
619
|
+ $mail_ids = [];
|
|
|
|
620
|
+ foreach ($ids['hits']['hits'] ?? [] as $item) {
|
|
|
|
621
|
+ $mail_ids[] = $item['_source']['uuid'];
|
|
|
|
622
|
+ }
|
|
906
|
|
623
|
|
|
907
|
- $sql = listsSql::all(dbWhere(['id'=>$mail_ids]),'`id`,`uid`,`email_id`,`folder_id`');
|
|
|
|
908
|
-// }
|
|
|
|
909
|
-// else{
|
|
|
|
910
|
-// $sql = listsSql::all(dbWhere(['id'=>$mail_ids,'email_id'=>array_column($emails,'id')]),'`id`,`uid`,`email_id`,`folder_id`');
|
624
|
+ $data = listsSql::all(db(), dbWhere(['id' => $mail_ids]), '`id`,`uid`,`email_id`,`folder_id`');
|
|
911
|
// }
|
625
|
// }
|
|
912
|
|
626
|
|
|
913
|
- $data = db()->all($sql);
|
|
|
|
914
|
-// $data2 = db()->all(str_replace('from `lists` where','from `lists_hot` where',$sql));
|
|
|
|
915
|
-// $data = array_merge($data,$data2);
|
|
|
|
916
|
- if($data){
|
627
|
+ if ($data) {
|
|
917
|
// 查询邮箱
|
628
|
// 查询邮箱
|
|
918
|
- $emails = array_column(db()->all(emailSql::all(dbWhere(['id'=>array_column($data,'email_id')]))),null,'id');
|
629
|
+ $emails = array_column(db()->all(emailSql::all(dbWhere(['id' => array_column($data, 'email_id')]))), null, 'id');
|
|
919
|
|
630
|
|
|
920
|
|
631
|
|
|
921
|
$uids = [];
|
632
|
$uids = [];
|
|
922
|
- foreach ($data as $datum){
|
|
|
|
923
|
- if(empty($uids[$datum['email_id']])){
|
633
|
+ foreach ($data as $datum) {
|
|
|
|
634
|
+ if (empty($uids[$datum['email_id']])) {
|
|
924
|
$uids[$datum['email_id']][$datum['folder_id']] = [];
|
635
|
$uids[$datum['email_id']][$datum['folder_id']] = [];
|
|
925
|
}
|
636
|
}
|
|
926
|
$uids[$datum['email_id']][$datum['folder_id']][] = [
|
637
|
$uids[$datum['email_id']][$datum['folder_id']][] = [
|
|
927
|
- 'uid' => $datum['uid'],
|
|
|
|
928
|
- 'id' => $datum['id'],
|
638
|
+ 'uid' => $datum['uid'],
|
|
|
|
639
|
+ 'id' => $datum['id'],
|
|
929
|
];
|
640
|
];
|
|
930
|
}
|
641
|
}
|
|
931
|
|
642
|
|
|
932
|
- foreach ($uids as $eid=>$arr){
|
|
|
|
933
|
- foreach ($arr as $fid=>$uid){
|
643
|
+ foreach ($uids as $eid => $arr) {
|
|
|
|
644
|
+ foreach ($arr as $fid => $uid) {
|
|
934
|
// 查询目录
|
645
|
// 查询目录
|
|
935
|
$folder = db()->first(folderSql::first($fid));
|
646
|
$folder = db()->first(folderSql::first($fid));
|
|
936
|
- if($folder){
|
647
|
+ if ($folder) {
|
|
937
|
// 开始远程
|
648
|
// 开始远程
|
|
938
|
- if(empty($emails[$eid])){
|
649
|
+ if (empty($emails[$eid])) {
|
|
939
|
$emails[$eid] = db()->first(emailSql::first($eid));
|
650
|
$emails[$eid] = db()->first(emailSql::first($eid));
|
|
940
|
}
|
651
|
}
|
|
941
|
|
652
|
|
|
942
|
- $mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
|
653
|
+ $mailInstance = new Mail($emails[$eid]['email'], base64_decode($emails[$eid]['password']), $emails[$eid]['imap']);
|
|
943
|
|
654
|
|
|
944
|
- if($mailInstance->login()==1){
|
|
|
|
945
|
- switch ($d){
|
655
|
+ if ($mailInstance->login() == 1) {
|
|
|
|
656
|
+ switch ($d) {
|
|
946
|
// 已读 未读
|
657
|
// 已读 未读
|
|
947
|
- case 'seen':{
|
|
|
|
948
|
- $mailInstance->seen(array_column($uid,'uid'),$folder['origin_folder'],$fv);
|
658
|
+ case 'seen':
|
|
|
|
659
|
+ {
|
|
|
|
660
|
+ $mailInstance->seen(array_column($uid, 'uid'), $folder['origin_folder'], $fv);
|
|
949
|
break;
|
661
|
break;
|
|
950
|
}
|
662
|
}
|
|
951
|
// 未回复/已回复
|
663
|
// 未回复/已回复
|
|
952
|
- case 'answered':{
|
|
|
|
953
|
- $mailInstance->answered(array_column($uid,'uid'),$folder['origin_folder'],$fv);
|
664
|
+ case 'answered':
|
|
|
|
665
|
+ {
|
|
|
|
666
|
+ $mailInstance->answered(array_column($uid, 'uid'), $folder['origin_folder'], $fv);
|
|
954
|
break;
|
667
|
break;
|
|
955
|
}
|
668
|
}
|
|
956
|
// 星标
|
669
|
// 星标
|
|
957
|
- case 'flagged':{
|
|
|
|
958
|
- $mailInstance->flagged(array_column($uid,'uid'),$folder['origin_folder'],$fv);
|
670
|
+ case 'flagged':
|
|
|
|
671
|
+ {
|
|
|
|
672
|
+ $mailInstance->flagged(array_column($uid, 'uid'), $folder['origin_folder'], $fv);
|
|
959
|
break;
|
673
|
break;
|
|
960
|
}
|
674
|
}
|
|
961
|
// 回收站,已删 未删,软删
|
675
|
// 回收站,已删 未删,软删
|
|
@@ -968,10 +682,8 @@ class Home extends Base { |
|
@@ -968,10 +682,8 @@ class Home extends Base { |
|
968
|
$mailInstance = null;
|
682
|
$mailInstance = null;
|
|
969
|
}
|
683
|
}
|
|
970
|
// 更新数据
|
684
|
// 更新数据
|
|
971
|
- db()->update(listsSql::$table,[
|
|
|
|
972
|
- $d => $fv
|
|
|
|
973
|
- ],dbWhere([
|
|
|
|
974
|
- 'id' => array_column($uid,'id')
|
685
|
+ listsSql::update(db(), [$d => $fv], dbWhere([
|
|
|
|
686
|
+ 'id' => array_column($uid, 'id')
|
|
975
|
]));
|
687
|
]));
|
|
976
|
|
688
|
|
|
977
|
}
|
689
|
}
|
|
@@ -983,7 +695,7 @@ class Home extends Base { |
|
@@ -983,7 +695,7 @@ class Home extends Base { |
|
983
|
|
695
|
|
|
984
|
|
696
|
|
|
985
|
app()->_json([
|
697
|
app()->_json([
|
|
986
|
- 'mail_id' => $mail_ids
|
698
|
+ 'mail_id' => $mail_ids
|
|
987
|
]);
|
699
|
]);
|
|
988
|
|
700
|
|
|
989
|
}
|
701
|
}
|
|
@@ -993,82 +705,78 @@ class Home extends Base { |
|
@@ -993,82 +705,78 @@ class Home extends Base { |
|
993
|
* @author:dc
|
705
|
* @author:dc
|
|
994
|
* @time 2023/4/1 9:24
|
706
|
* @time 2023/4/1 9:24
|
|
995
|
*/
|
707
|
*/
|
|
996
|
- public function info(){
|
|
|
|
997
|
- $reload = app()->request('reload',0,'intval');
|
708
|
+ public function info()
|
|
|
|
709
|
+ {
|
|
|
|
710
|
+ $reload = app()->request('reload', 0, 'intval');
|
|
998
|
$sync_num = 0;
|
711
|
$sync_num = 0;
|
|
999
|
HOME_INFO_BODY:
|
712
|
HOME_INFO_BODY:
|
|
1000
|
- $id = app()->request('id',0,'intval');
|
713
|
+ $id = app()->request('id', 0, 'intval');
|
|
1001
|
|
714
|
|
|
1002
|
- $udate = app()->request('udate',0,'intval');
|
715
|
+ $udate = app()->request('udate', 0, 'intval');
|
|
1003
|
$subject = app()->request('subject');
|
716
|
$subject = app()->request('subject');
|
|
1004
|
- if($udate&&$subject){
|
|
|
|
1005
|
- $data = db()->first(listsSql::first(dbWhere(['id'=>$id,'udate'=>$udate])));
|
|
|
|
1006
|
-// if($data && trim($data['subject']) != trim($subject)){
|
|
|
|
1007
|
-// $data = [];
|
|
|
|
1008
|
-// }
|
|
|
|
1009
|
- if($data){
|
717
|
+ if ($udate && $subject) {
|
|
|
|
718
|
+ $data = listsSql::first(db(), dbWhere(['id' => $id, 'udate' => $udate]));
|
|
|
|
719
|
+ if ($data) {
|
|
1010
|
$email = db()->first(emailSql::first($data['email_id']));
|
720
|
$email = db()->first(emailSql::first($data['email_id']));
|
|
1011
|
}
|
721
|
}
|
|
1012
|
- }else{
|
722
|
+ } else {
|
|
1013
|
// 没有,说明没有同步过来
|
723
|
// 没有,说明没有同步过来
|
|
1014
|
- $email = $this->getEmail('*',false);
|
|
|
|
1015
|
- $data = db()->first(listsSql::first(dbWhere(['id'=>$id])));
|
|
|
|
1016
|
- if(!$data){
|
|
|
|
1017
|
- $data = db()->first(listsSql::firstHot(dbWhere(['id'=>$id])));
|
|
|
|
1018
|
- }
|
|
|
|
1019
|
- if($data){
|
724
|
+ $email = $this->getEmail('*', false);
|
|
|
|
725
|
+ $data = listsSql::first(db(), dbWhere(['id' => $id]));
|
|
|
|
726
|
+
|
|
|
|
727
|
+ if ($data) {
|
|
1020
|
$email = db()->first(emailSql::first($data['email_id']));
|
728
|
$email = db()->first(emailSql::first($data['email_id']));
|
|
1021
|
}
|
729
|
}
|
|
1022
|
|
730
|
|
|
1023
|
}
|
731
|
}
|
|
1024
|
|
732
|
|
|
1025
|
- if($data){
|
|
|
|
1026
|
- $data['uuid'] = get_email_uuid($data['subject'],$data['udate'],$data['from'],$data['to'],$data['size']);
|
733
|
+ if ($data) {
|
|
|
|
734
|
+ $data['uuid'] = get_email_uuid($data['subject'], $data['udate'], $data['from'], $data['to'], $data['size']);
|
|
1027
|
|
735
|
|
|
1028
|
- $data['description'] = @html_entity_decode($data['description']??'', ENT_COMPAT, 'UTF-8');
|
736
|
+ $data['description'] = @html_entity_decode($data['description'] ?? '', ENT_COMPAT, 'UTF-8');
|
|
1029
|
|
737
|
|
|
1030
|
- $data['to_name'] = $data['to_name'] ? json_decode($data['to_name'],true) : [];
|
|
|
|
1031
|
- if(!$data['to_name']){
|
|
|
|
1032
|
- $data['to_name'] = [["email"=>$email['email'],'name'=>'']];
|
738
|
+ $data['to_name'] = $data['to_name'] ? json_decode($data['to_name'], true) : [];
|
|
|
|
739
|
+ if (!$data['to_name']) {
|
|
|
|
740
|
+ $data['to_name'] = [["email" => $email['email'], 'name' => '']];
|
|
1033
|
}
|
741
|
}
|
|
1034
|
- $data['cc'] = $data['cc'] ? json_decode($data['cc'],true) : [];
|
|
|
|
1035
|
- $data['bcc'] = $data['bcc'] ? json_decode($data['bcc'],true) : [];
|
742
|
+ $data['cc'] = $data['cc'] ? json_decode($data['cc'], true) : [];
|
|
|
|
743
|
+ $data['bcc'] = $data['bcc'] ? json_decode($data['bcc'], true) : [];
|
|
1036
|
|
744
|
|
|
1037
|
- $data['to_name'] = array_map(function ($t){
|
|
|
|
1038
|
- if(!empty($t['name'])){
|
745
|
+ $data['to_name'] = array_map(function ($t) {
|
|
|
|
746
|
+ if (!empty($t['name'])) {
|
|
1039
|
$t['name'] = MailFun::mb_coding($t['name']);
|
747
|
$t['name'] = MailFun::mb_coding($t['name']);
|
|
1040
|
}
|
748
|
}
|
|
1041
|
return $t;
|
749
|
return $t;
|
|
1042
|
- },$data['to_name']);
|
750
|
+ }, $data['to_name']);
|
|
1043
|
|
751
|
|
|
1044
|
- $postid = app()->request('postid','','intval');
|
|
|
|
1045
|
- $esData = ($postid ? es('email_lists_branch_'.$postid) : es())->get(['id'=>$data['email_id'].'_'.$data['folder_id'].'_'.$data['uid']]);
|
|
|
|
1046
|
- $data['postid'] = $esData['_source']['postid']??0;
|
752
|
+ $postid = app()->request('postid', '', 'intval');
|
|
|
|
753
|
+ $esData = ($postid ? es('email_lists_branch_' . $postid) : es())->get(['id' => $data['email_id'] . '_' . $data['folder_id'] . '_' . $data['uid']]);
|
|
|
|
754
|
+ $data['postid'] = $esData['_source']['postid'] ?? 0;
|
|
1047
|
|
755
|
|
|
1048
|
// 是否再次 重新获取
|
756
|
// 是否再次 重新获取
|
|
1049
|
- $data['allowreply'] = db()->value(folderSql::first(['id'=>$data['folder_id']],'folder'))!='发件箱'?1:0;
|
757
|
+ $data['allowreply'] = db()->value(folderSql::first(['id' => $data['folder_id']], 'folder')) != '发件箱' ? 1 : 0;
|
|
1050
|
|
758
|
|
|
1051
|
- $body = getMailBody($id);
|
|
|
|
1052
|
- if($body && !$reload){
|
|
|
|
1053
|
- $data['body'] = json_decode($body['text_html'],true);
|
759
|
+ $body = getMailBody($id);
|
|
|
|
760
|
+ if ($body && !$reload) {
|
|
|
|
761
|
+ $data['body'] = json_decode($body['text_html'], true);
|
|
1054
|
$htmlbody = '';
|
762
|
$htmlbody = '';
|
|
1055
|
- foreach ($data['body'] as $bd){
|
763
|
+ foreach ($data['body'] as $bd) {
|
|
1056
|
// if(!empty($bd['charset'])){
|
764
|
// if(!empty($bd['charset'])){
|
|
1057
|
// $charset = $bd['charset'];
|
765
|
// $charset = $bd['charset'];
|
|
1058
|
// }
|
766
|
// }
|
|
1059
|
- if(($bd['type']??'') == 'text/html'){
|
767
|
+ if (($bd['type'] ?? '') == 'text/html') {
|
|
1060
|
$htmlbody = base64_decode($bd['body']);
|
768
|
$htmlbody = base64_decode($bd['body']);
|
|
1061
|
}
|
769
|
}
|
|
1062
|
}
|
770
|
}
|
|
1063
|
- foreach ($data['body'] as $bdk=>$bd){
|
771
|
+ foreach ($data['body'] as $bdk => $bd) {
|
|
1064
|
|
772
|
|
|
1065
|
- if(count($bd)==1){
|
|
|
|
1066
|
- if(isset($bd['body'])){
|
773
|
+ if (count($bd) == 1) {
|
|
|
|
774
|
+ if (isset($bd['body'])) {
|
|
1067
|
$data['body'][$bdk]['type'] = 'text/html';
|
775
|
$data['body'][$bdk]['type'] = 'text/html';
|
|
1068
|
}
|
776
|
}
|
|
1069
|
}
|
777
|
}
|
|
1070
|
|
778
|
|
|
1071
|
- if(!empty($bd['path'])){
|
779
|
+ if (!empty($bd['path'])) {
|
|
1072
|
|
780
|
|
|
1073
|
$data['body'][$bdk]['name'] = MailFun::isBase64($bd['name']) ? @base64_decode($bd['name']) : $bd['name'];
|
781
|
$data['body'][$bdk]['name'] = MailFun::isBase64($bd['name']) ? @base64_decode($bd['name']) : $bd['name'];
|
|
1074
|
$data['body'][$bdk]['filename'] = MailFun::isBase64($bd['filename']) ? @base64_decode($bd['filename']) : $bd['filename'];
|
782
|
$data['body'][$bdk]['filename'] = MailFun::isBase64($bd['filename']) ? @base64_decode($bd['filename']) : $bd['filename'];
|
|
@@ -1080,15 +788,15 @@ class Home extends Base { |
|
@@ -1080,15 +788,15 @@ class Home extends Base { |
|
1080
|
|
788
|
|
|
1081
|
$data['body'][$bdk]['size'] = 0;
|
789
|
$data['body'][$bdk]['size'] = 0;
|
|
1082
|
$data['body'][$bdk]['url'] = '';
|
790
|
$data['body'][$bdk]['url'] = '';
|
|
1083
|
- if(is_file($bd['path'])){
|
791
|
+ if (is_file($bd['path'])) {
|
|
1084
|
// 文件大小
|
792
|
// 文件大小
|
|
1085
|
$data['body'][$bdk]['size'] = filesize($bd['path']);
|
793
|
$data['body'][$bdk]['size'] = filesize($bd['path']);
|
|
1086
|
// 文件访问地址
|
794
|
// 文件访问地址
|
|
1087
|
- $data['body'][$bdk]['url'] = APP_HOST.str_replace(PUBLIC_PATH,'',$bd['path']);
|
795
|
+ $data['body'][$bdk]['url'] = APP_HOST . str_replace(PUBLIC_PATH, '', $bd['path']);
|
|
1088
|
}
|
796
|
}
|
|
1089
|
|
797
|
|
|
1090
|
// 验证编码是否有其他编码字符,这里编辑了未知编码
|
798
|
// 验证编码是否有其他编码字符,这里编辑了未知编码
|
|
1091
|
- if(!@json_encode($data['body'][$bdk])){
|
799
|
+ if (!@json_encode($data['body'][$bdk])) {
|
|
1092
|
// 抛弃原有的名字,显示已存储到服务器的名字
|
800
|
// 抛弃原有的名字,显示已存储到服务器的名字
|
|
1093
|
$data['body'][$bdk]['name'] = $data['body'][$bdk]['signName'];
|
801
|
$data['body'][$bdk]['name'] = $data['body'][$bdk]['signName'];
|
|
1094
|
$data['body'][$bdk]['filename'] = $data['body'][$bdk]['signName'];
|
802
|
$data['body'][$bdk]['filename'] = $data['body'][$bdk]['signName'];
|
|
@@ -1097,35 +805,34 @@ class Home extends Base { |
|
@@ -1097,35 +805,34 @@ class Home extends Base { |
|
1097
|
unset($data['body'][$bdk]['path']);
|
805
|
unset($data['body'][$bdk]['path']);
|
|
1098
|
|
806
|
|
|
1099
|
// 内容区是有有cid
|
807
|
// 内容区是有有cid
|
|
1100
|
- if ($htmlbody && !empty($bd['content-id'])){
|
|
|
|
1101
|
- if(!strpos($htmlbody,"\"cid:{$bd['content-id']}\"")){
|
808
|
+ if ($htmlbody && !empty($bd['content-id'])) {
|
|
|
|
809
|
+ if (!strpos($htmlbody, "\"cid:{$bd['content-id']}\"")) {
|
|
1102
|
unset($data['body'][$bdk]['content-id']);
|
810
|
unset($data['body'][$bdk]['content-id']);
|
|
1103
|
}
|
811
|
}
|
|
1104
|
- }
|
|
|
|
1105
|
- // 没有html内容,content-id是不可能有的
|
|
|
|
1106
|
- else if(!$htmlbody){
|
812
|
+ } // 没有html内容,content-id是不可能有的
|
|
|
|
813
|
+ else if (!$htmlbody) {
|
|
1107
|
unset($data['body'][$bdk]['content-id']);
|
814
|
unset($data['body'][$bdk]['content-id']);
|
|
1108
|
}
|
815
|
}
|
|
1109
|
}
|
816
|
}
|
|
1110
|
}
|
817
|
}
|
|
1111
|
return [
|
818
|
return [
|
|
1112
|
- 'data' => $data
|
819
|
+ 'data' => $data
|
|
1113
|
];
|
820
|
];
|
|
1114
|
}// 草稿
|
821
|
}// 草稿
|
|
1115
|
- else if(!$data['uid'] && $data['draft']){
|
822
|
+ else if (!$data['uid'] && $data['draft']) {
|
|
1116
|
$data['body'] = [];
|
823
|
$data['body'] = [];
|
|
1117
|
return [
|
824
|
return [
|
|
1118
|
- 'data' => $data
|
825
|
+ 'data' => $data
|
|
1119
|
];
|
826
|
];
|
|
1120
|
}
|
827
|
}
|
|
1121
|
|
828
|
|
|
1122
|
// 循环几次
|
829
|
// 循环几次
|
|
1123
|
- if($data['uid'] >= 0 && $sync_num < 1){
|
|
|
|
1124
|
- $folder = db()->value(folderSql::first(['id'=>$data['folder_id']],'origin_folder'));
|
|
|
|
1125
|
- try{
|
|
|
|
1126
|
- (new SyncMail(db()->first(emailSql::first($data['email_id']))))->mail($folder,[$data['uid']],true);
|
|
|
|
1127
|
- }catch (\Throwable $e){
|
|
|
|
1128
|
- logs('read body:'.$e->getMessage().$e->getTraceAsString());
|
830
|
+ if ($data['uid'] >= 0 && $sync_num < 1) {
|
|
|
|
831
|
+ $folder = db()->value(folderSql::first(['id' => $data['folder_id']], 'origin_folder'));
|
|
|
|
832
|
+ try {
|
|
|
|
833
|
+ (new SyncMail(db()->first(emailSql::first($data['email_id']))))->mail($folder, [$data['uid']], true);
|
|
|
|
834
|
+ } catch (\Throwable $e) {
|
|
|
|
835
|
+ logs('read body:' . $e->getMessage() . $e->getTraceAsString());
|
|
1129
|
app()->e('邮箱登录验证异常');
|
836
|
app()->e('邮箱登录验证异常');
|
|
1130
|
}
|
837
|
}
|
|
1131
|
|
838
|
|
|
@@ -1133,10 +840,10 @@ class Home extends Base { |
|
@@ -1133,10 +840,10 @@ class Home extends Base { |
|
1133
|
$reload = 0;
|
840
|
$reload = 0;
|
|
1134
|
goto HOME_INFO_BODY;
|
841
|
goto HOME_INFO_BODY;
|
|
1135
|
}
|
842
|
}
|
|
1136
|
- logs('超过读取body次数 '.$data['id']);
|
843
|
+ logs('超过读取body次数 ' . $data['id']);
|
|
1137
|
|
844
|
|
|
1138
|
- }else{
|
|
|
|
1139
|
- logs('读取body 没有查询到数据 '.$id.'-'.($email['email']??''));
|
845
|
+ } else {
|
|
|
|
846
|
+ logs('读取body 没有查询到数据 ' . $id . '-' . ($email['email'] ?? ''));
|
|
1140
|
}
|
847
|
}
|
|
1141
|
|
848
|
|
|
1142
|
app()->e('mail_body_error');
|
849
|
app()->e('mail_body_error');
|
|
@@ -1149,8 +856,9 @@ class Home extends Base { |
|
@@ -1149,8 +856,9 @@ class Home extends Base { |
|
1149
|
* @author:dc
|
856
|
* @author:dc
|
|
1150
|
* @time 2024/8/7 14:12
|
857
|
* @time 2024/8/7 14:12
|
|
1151
|
*/
|
858
|
*/
|
|
1152
|
- public function desubscribe(){
|
|
|
|
1153
|
- $key = app()->request('key','');
|
859
|
+ public function desubscribe()
|
|
|
|
860
|
+ {
|
|
|
|
861
|
+ $key = app()->request('key', '');
|
|
1154
|
app()->_json(MailFun::deSubscribeUrl($key));
|
862
|
app()->_json(MailFun::deSubscribeUrl($key));
|
|
1155
|
}
|
863
|
}
|
|
1156
|
|
864
|
|
|
@@ -1161,21 +869,23 @@ class Home extends Base { |
|
@@ -1161,21 +869,23 @@ class Home extends Base { |
|
1161
|
* @author:dc
|
869
|
* @author:dc
|
|
1162
|
* @time 2025/7/17 9:50
|
870
|
* @time 2025/7/17 9:50
|
|
1163
|
*/
|
871
|
*/
|
|
1164
|
- public function bodyinfo(){
|
872
|
+ public function bodyinfo()
|
|
|
|
873
|
+ {
|
|
1165
|
$id = app()->request('list_id');
|
874
|
$id = app()->request('list_id');
|
|
1166
|
|
875
|
|
|
1167
|
$body = getMailBody($id);
|
876
|
$body = getMailBody($id);
|
|
1168
|
- if(!$body){
|
|
|
|
1169
|
- $data = db()->first(listsSql::first(dbWhere(['id'=>$id]),'folder_id,email_id,uid'));
|
|
|
|
1170
|
- $folder = db()->value(folderSql::first(['id'=>$data['folder_id']],'origin_folder'));
|
|
|
|
1171
|
- try{
|
|
|
|
1172
|
- (new SyncMail($data['email_id']))->mail($folder,[$data['uid']],true);
|
|
|
|
1173
|
- }catch (\Throwable $e){}
|
877
|
+ if (!$body) {
|
|
|
|
878
|
+ $data = listsSql::first(db(), dbWhere(['id' => $id]), 'folder_id,email_id,uid');
|
|
|
|
879
|
+ $folder = db()->value(folderSql::first(['id' => $data['folder_id']], 'origin_folder'));
|
|
|
|
880
|
+ try {
|
|
|
|
881
|
+ (new SyncMail($data['email_id']))->mail($folder, [$data['uid']], true);
|
|
|
|
882
|
+ } catch (\Throwable $e) {
|
|
|
|
883
|
+ }
|
|
1174
|
}
|
884
|
}
|
|
1175
|
|
885
|
|
|
1176
|
$body = getMailBody($id);
|
886
|
$body = getMailBody($id);
|
|
1177
|
|
887
|
|
|
1178
|
- app()->_json(@json_decode($body['text_html']??"[]",true));
|
888
|
+ app()->_json(@json_decode($body['text_html'] ?? "[]", true));
|
|
1179
|
|
889
|
|
|
1180
|
}
|
890
|
}
|
|
1181
|
|
891
|
|
|
@@ -1185,22 +895,23 @@ class Home extends Base { |
|
@@ -1185,22 +895,23 @@ class Home extends Base { |
|
1185
|
* @author:dc
|
895
|
* @author:dc
|
|
1186
|
* @time 2025/9/18 16:50
|
896
|
* @time 2025/9/18 16:50
|
|
1187
|
*/
|
897
|
*/
|
|
1188
|
- public function resync_to_es(){
|
|
|
|
1189
|
- $postid = (int) app()->request('postid');
|
|
|
|
1190
|
- if(app()->request('postid')=='0a'){
|
|
|
|
1191
|
- redis()->rPush('resync_to_es_inbox_list','0a');
|
898
|
+ public function resync_to_es()
|
|
|
|
899
|
+ {
|
|
|
|
900
|
+ $postid = (int)app()->request('postid');
|
|
|
|
901
|
+ if (app()->request('postid') == '0a') {
|
|
|
|
902
|
+ redis()->rPush('resync_to_es_inbox_list', '0a');
|
|
1192
|
return;
|
903
|
return;
|
|
1193
|
}
|
904
|
}
|
|
1194
|
|
905
|
|
|
1195
|
- if(redis()->has('resync_to_es_inbox:'.$postid)){
|
906
|
+ if (redis()->has('resync_to_es_inbox:' . $postid)) {
|
|
1196
|
app()->e('失败,请等待10分钟后在重试');
|
907
|
app()->e('失败,请等待10分钟后在重试');
|
|
1197
|
}
|
908
|
}
|
|
1198
|
- $h = (int) date('H');
|
|
|
|
1199
|
- if(!$postid && $h>=6&& $h<=18){
|
909
|
+ $h = (int)date('H');
|
|
|
|
910
|
+ if (!$postid && $h >= 6 && $h <= 18) {
|
|
1200
|
app()->e('刷所有项目只能在早6点前或晚18点后');
|
911
|
app()->e('刷所有项目只能在早6点前或晚18点后');
|
|
1201
|
}
|
912
|
}
|
|
1202
|
|
913
|
|
|
1203
|
- redis()->rPush('resync_to_es_inbox_list',$postid);
|
914
|
+ redis()->rPush('resync_to_es_inbox_list', $postid);
|
|
1204
|
|
915
|
|
|
1205
|
app()->e('请求成功,请等待5-15分钟');
|
916
|
app()->e('请求成功,请等待5-15分钟');
|
|
1206
|
|
917
|
|
|
@@ -1214,29 +925,21 @@ class Home extends Base { |
|
@@ -1214,29 +925,21 @@ class Home extends Base { |
|
1214
|
* @author:dc
|
925
|
* @author:dc
|
|
1215
|
* @time 2025/11/27 14:16
|
926
|
* @time 2025/11/27 14:16
|
|
1216
|
*/
|
927
|
*/
|
|
1217
|
- public function my_resync_to_es(){
|
928
|
+ public function my_resync_to_es()
|
|
|
|
929
|
+ {
|
|
1218
|
$id = 0;
|
930
|
$id = 0;
|
|
1219
|
$total = 0;
|
931
|
$total = 0;
|
|
1220
|
$email_id = intval(app()->request('email_id'));
|
932
|
$email_id = intval(app()->request('email_id'));
|
|
1221
|
- while (1){
|
|
|
|
1222
|
-// echo $id."\n";
|
|
|
|
1223
|
- $mailLists = db()->all("select `id` from `lists` where `email_id` = {$email_id} and `id` > {$id} order by `id` asc limit 1000");
|
|
|
|
1224
|
- if(empty($mailLists)){
|
|
|
|
1225
|
- break;
|
|
|
|
1226
|
- }
|
|
|
|
1227
|
- foreach ($mailLists as $mailList){
|
|
|
|
1228
|
- $total++;
|
|
|
|
1229
|
- $id = $mailList['id'];
|
|
|
|
1230
|
- redis()->rPush('sync_to_es',$id.'.1');
|
|
|
|
1231
|
- }
|
933
|
+ $mailLists = listsSql::all(db(), dbWhere(['email_id' => $email_id]), 'id');
|
|
|
|
934
|
+ foreach ($mailLists as $mailList) {
|
|
|
|
935
|
+ $total++;
|
|
|
|
936
|
+ $id = $mailList['id'];
|
|
|
|
937
|
+ redis()->rPush('sync_to_es', $id . '.1');
|
|
1232
|
}
|
938
|
}
|
|
1233
|
-
|
|
|
|
1234
|
return $total;
|
939
|
return $total;
|
|
1235
|
}
|
940
|
}
|
|
1236
|
|
941
|
|
|
1237
|
|
942
|
|
|
1238
|
-
|
|
|
|
1239
|
-
|
|
|
|
1240
|
}
|
943
|
}
|
|
1241
|
|
944
|
|
|
1242
|
|
945
|
|