iobroker.imap 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/imap_event.js CHANGED
@@ -33,7 +33,7 @@ module.exports = {
33
33
  val: JSON.stringify(mailbox),
34
34
  ack: true,
35
35
  });
36
- await this.loadAllSeqno(client, "INBOX");
36
+ await this.loadAllSeqno(client, "INBOX", false);
37
37
  if (this.clients[client].serverSupports("SORT")) {
38
38
  this.readMailsSort(client);
39
39
  } else {
@@ -45,6 +45,7 @@ module.exports = {
45
45
  },
46
46
  /**
47
47
  * Read Mail with search criteria and capability SORT == true
48
+ *
48
49
  * @param {string} client client id
49
50
  */
50
51
  readMailsSort(client) {
@@ -59,7 +60,9 @@ module.exports = {
59
60
  this.all_seqno[client] = [];
60
61
  results.sort((a, b) => b - a);
61
62
  for (const result of results) {
62
- if (count > this.clientsRaw[client].max) break;
63
+ if (count > this.clientsRaw[client].max) {
64
+ break;
65
+ }
63
66
  if (this.clientsRaw[client].att) {
64
67
  await this.findmail(client, result, count, all, true);
65
68
  } else {
@@ -74,6 +77,7 @@ module.exports = {
74
77
  },
75
78
  /**
76
79
  * Read Mail with search criteria and capability SORT == false
80
+ *
77
81
  * @param {string} client client id
78
82
  */
79
83
  readMails(client) {
@@ -94,7 +98,9 @@ module.exports = {
94
98
  this.all_seqno[client] = [];
95
99
  results.sort((a, b) => b - a);
96
100
  for (const result of results) {
97
- if (count > this.clientsRaw[client].max) break;
101
+ if (count > this.clientsRaw[client].max) {
102
+ break;
103
+ }
98
104
  if (this.clientsRaw[client].att) {
99
105
  await this.findmail(client, result, count, all, false);
100
106
  } else {
@@ -115,7 +121,7 @@ module.exports = {
115
121
  * @param {boolean} sort
116
122
  */
117
123
  async findmail_wo_att(client, result, counter, all, sort) {
118
- return new Promise((resolve) => {
124
+ return new Promise(resolve => {
119
125
  try {
120
126
  let attrs;
121
127
  let header_mail;
@@ -123,11 +129,11 @@ module.exports = {
123
129
  bodies: ["TEXT"],
124
130
  struct: true,
125
131
  });
126
- f.on("message", (msg) => {
127
- msg.once("attributes", (att) => {
132
+ f.on("message", msg => {
133
+ msg.once("attributes", att => {
128
134
  attrs = att;
129
135
  });
130
- msg.on("body", async (stream) => {
136
+ msg.on("body", async stream => {
131
137
  header_mail = stream;
132
138
  stream.resume();
133
139
  });
@@ -145,14 +151,14 @@ module.exports = {
145
151
  });
146
152
  e.on("message", (next_msg, seqno) => {
147
153
  let new_attrs;
148
- next_msg.once("attributes", (att) => {
154
+ next_msg.once("attributes", att => {
149
155
  new_attrs = att;
150
156
  });
151
157
  next_msg.on("body", async (stream, info) => {
152
158
  let mail;
153
159
  try {
154
160
  mail = await simpleParser(stream, this.clientsRaw[client].node_option);
155
- } catch (e) {
161
+ } catch {
156
162
  mail = this.current_date(client);
157
163
  }
158
164
  const att = {
@@ -163,7 +169,7 @@ module.exports = {
163
169
  let mail_header;
164
170
  try {
165
171
  mail_header = await simpleParser(header_mail, this.clientsRaw[client].node_option);
166
- } catch (e) {
172
+ } catch {
167
173
  header_mail = this.current_date(client);
168
174
  }
169
175
  mail.text = mail_header.text != null ? mail_header.text : "";
@@ -172,20 +178,22 @@ module.exports = {
172
178
  }
173
179
  mail.attachments = all_att.attach;
174
180
  mail.attachments_info = all_att.attach_info;
175
- if (mail.headerLines) mail.headerLines = [];
181
+ if (mail.headerLines) {
182
+ mail.headerLines = [];
183
+ }
176
184
  this.setMail(mail, seqno, att, info, client, counter, all, sort);
177
185
  stream.resume();
178
186
  resolve(true);
179
187
  });
180
188
  });
181
- e.once("error", (error) => {
189
+ e.once("error", error => {
182
190
  if (error) {
183
191
  this.log_translator("error", "Error", client, error);
184
192
  }
185
193
  resolve(false);
186
194
  });
187
195
  });
188
- f.once("error", (error) => {
196
+ f.once("error", error => {
189
197
  if (error) {
190
198
  this.log_translator("error", "Error", client, error);
191
199
  }
@@ -205,7 +213,7 @@ module.exports = {
205
213
  * @param {boolean} sort
206
214
  */
207
215
  async findmail(client, result, counter, all, sort) {
208
- return new Promise((resolve) => {
216
+ return new Promise(resolve => {
209
217
  try {
210
218
  const f = this.clients[client].fetch(result, {
211
219
  bodies: "",
@@ -214,26 +222,28 @@ module.exports = {
214
222
  f.on("message", (msg, seqno) => {
215
223
  let attrs;
216
224
  this.all_seqno[client].push(seqno);
217
- msg.on("attributes", (att) => {
225
+ msg.on("attributes", att => {
218
226
  attrs = att;
219
227
  });
220
228
  msg.on("body", async (stream, info) => {
221
229
  let mail;
222
230
  try {
223
231
  mail = await simpleParser(stream, this.clientsRaw[client].node_option);
224
- } catch (e) {
232
+ } catch {
225
233
  mail = this.current_date(client);
226
234
  }
227
235
  const all_att = await this.updateattachments(attrs);
228
236
  mail.attachments = all_att.attach;
229
237
  mail.attachments_info = all_att.attach_info;
230
- if (mail.headerLines) mail.headerLines = [];
238
+ if (mail.headerLines) {
239
+ mail.headerLines = [];
240
+ }
231
241
  this.setMail(mail, seqno, attrs, info, client, counter, all, sort);
232
242
  stream.resume();
233
243
  resolve(true);
234
244
  });
235
245
  });
236
- f.once("error", (error) => {
246
+ f.once("error", error => {
237
247
  if (error) {
238
248
  this.log_translator("error", "Error", client, error);
239
249
  }
@@ -279,7 +289,7 @@ module.exports = {
279
289
  * @param {string} client client id
280
290
  */
281
291
  subscribeBox(mailboxname, client) {
282
- this.clients[client].subscribeBox(mailboxname, (error) => {
292
+ this.clients[client].subscribeBox(mailboxname, error => {
283
293
  if (error) {
284
294
  this.log_translator("error", "Error", client, error);
285
295
  } else {
@@ -289,11 +299,12 @@ module.exports = {
289
299
  },
290
300
  /**
291
301
  * Event for delete or move
302
+ *
292
303
  * @param {number} seqno
293
304
  * @param {string} client client id
294
305
  */
295
306
  onExpunge(seqno, client) {
296
- const isRange = this.all_seqno[client].findIndex((number) => number == seqno);
307
+ const isRange = this.all_seqno[client].findIndex(number => number == seqno);
297
308
  if (isRange != -1 && (isRange < this.clientsRaw[client].max || isRange == this.clientsRaw[client].max)) {
298
309
  this.log_translator("info", "EMail deleted in scope", client, seqno);
299
310
  this.clientsRaw[client].isonExpunge = true;
@@ -331,9 +342,11 @@ module.exports = {
331
342
  this.clientsRaw[client].onExpunge = 0;
332
343
  this.clientsRaw[client].isonExpunge = false;
333
344
  }, 1000);
345
+ this.updateTotal(client, this.clientsRaw[client].inbox_activ);
334
346
  },
335
347
  /**
336
348
  * Event if UIDs in this mailbox have changed since the last time this mailbox was opened.
349
+ *
337
350
  * @param {number} uidvalidity
338
351
  * @param {string} client client id
339
352
  */
@@ -342,6 +355,7 @@ module.exports = {
342
355
  },
343
356
  /**
344
357
  * Event with value total, new, unseen
358
+ *
345
359
  * @param {object} message
346
360
  * @param {string} client client id
347
361
  */
@@ -378,6 +392,7 @@ module.exports = {
378
392
  /**
379
393
  * @param {string|object} err
380
394
  * @param {string} clientID client id
395
+ * @param {string} where
381
396
  */
382
397
  onErrorImap(err, clientID, where) {
383
398
  let level = "warn";
@@ -393,6 +408,7 @@ module.exports = {
393
408
  },
394
409
  /**
395
410
  * Status current folder (total and unseen)
411
+ *
396
412
  * @param {string} folder
397
413
  * @param {string} client client id
398
414
  */
@@ -419,14 +435,18 @@ module.exports = {
419
435
  * @param {boolean} [second=false]
420
436
  */
421
437
  loadAllSeqno(client, inbox, second) {
422
- return new Promise((resolve) => {
438
+ return new Promise(resolve => {
423
439
  this.clients[client].search(["ALL"], async (error, results) => {
424
440
  if (error) {
425
441
  this.log_translator("error", "Error", client, error);
426
- if (!second) this.clientsRaw[client][inbox] = [];
442
+ if (!second) {
443
+ this.clientsRaw[client][inbox] = [];
444
+ }
427
445
  resolve([]);
428
446
  }
429
- if (!second) this.clientsRaw[client][inbox] = results;
447
+ if (!second) {
448
+ this.clientsRaw[client][inbox] = results;
449
+ }
430
450
  resolve(results);
431
451
  });
432
452
  });
@@ -434,6 +454,7 @@ module.exports = {
434
454
  /**
435
455
  * Read all uids from active mailbox
436
456
  * Return total and unread
457
+ *
437
458
  * @param {string} client device id
438
459
  * @param {string} inbox folder name
439
460
  */
@@ -443,25 +464,26 @@ module.exports = {
443
464
  let count_all = 0;
444
465
  try {
445
466
  count_unseen = unseen.length;
446
- } catch (e) {
467
+ } catch {
447
468
  count_unseen = 0;
448
469
  }
449
470
  try {
450
471
  count_all = this.clientsRaw[client][inbox].length;
451
- } catch (e) {
472
+ } catch {
452
473
  count_all = 0;
453
474
  }
454
- await this.setStateAsync(`${client}.total`, {
475
+ await this.setState(`${client}.total`, {
455
476
  val: count_all,
456
477
  ack: true,
457
478
  });
458
- await this.setStateAsync(`${client}.total_unread`, {
479
+ await this.setState(`${client}.total_unread`, {
459
480
  val: count_unseen,
460
481
  ack: true,
461
482
  });
462
483
  },
463
484
  /**
464
485
  * Event when new mail arrives in the currently open mailbox
486
+ *
465
487
  * @param {object} box
466
488
  * @param {object} info
467
489
  * @param {object} curReq
@@ -478,8 +500,10 @@ module.exports = {
478
500
  },
479
501
  /**
480
502
  * Event when new mail arrives in the currently open mailbox
503
+ *
481
504
  * @param {object} box
482
505
  * @param {object} info
506
+ * @param {string} state
483
507
  * @param {string} client device id
484
508
  */
485
509
  async onNew(box, info, state, client) {
@@ -487,6 +511,7 @@ module.exports = {
487
511
  },
488
512
  /**
489
513
  * Event when new mail arrives in the currently open mailbox
514
+ *
490
515
  * @param {number} count counter new mail
491
516
  * @param {object} box
492
517
  * @param {object} info
@@ -501,12 +526,17 @@ module.exports = {
501
526
  this.setUpdate(client, { flags: [], new_mail: count }, "new mail");
502
527
  const inbox = this.clientsRaw[client].inbox_activ;
503
528
  const new_mail = await this.loadAllSeqno(client, inbox, true);
504
- const uidNext = this.clientsRaw[client][inbox] != null ? this.clientsRaw[client][inbox] : [box.uidnext];
529
+ this.log_translator("debug", "logs", `inbox: ${inbox}`);
530
+ this.log_translator("debug", "logs", `clientsRaw: ${this.clientsRaw[client][inbox]}`);
531
+ this.log_translator("debug", "logs", `uidnext: ${box.uidnext}`);
532
+ this.log_translator("debug", "logs", `new_mail: ${new_mail}`);
533
+ const uidNext = this.clientsRaw[client][inbox] != null ? this.clientsRaw[client][inbox] : [box.uidnext - 1];
505
534
  let nextuid = this.diffArray(uidNext, new_mail, 2, client);
506
535
  this.clientsRaw[client][inbox] = new_mail;
507
536
  if (nextuid === 0 || nextuid.length === 0) {
508
537
  nextuid = [box.uidnext];
509
538
  }
539
+ this.log_translator("debug", "logs", `nextuid: ${nextuid}`);
510
540
  if (this.clients[client].serverSupports("SORT")) {
511
541
  this.newMails(client, nextuid, "new", true);
512
542
  } else {
@@ -531,14 +561,15 @@ module.exports = {
531
561
  /**
532
562
  * Arrival new Mail and capability SORT == false -> Use nextuid
533
563
  * Arrival new Mail and capability SORT == true
564
+ *
534
565
  * @param {string} client device id
535
566
  * @param {object} uid
536
567
  * @param {string} what new mail or update
537
568
  * @param {boolean} sort Implementation in the next release
538
569
  */
539
570
  newMails(client, uid, what, sort) {
540
- this.log.debug(sort);
541
- this.log.debug("newMail: " + JSON.stringify(uid));
571
+ this.log_translator("debug", "logs", `sort: ${sort}`);
572
+ this.log_translator("debug", "logs", `newMail: ${JSON.stringify(uid)}`);
542
573
  for (const uids of uid) {
543
574
  let attrs;
544
575
  let header_mail;
@@ -546,11 +577,11 @@ module.exports = {
546
577
  bodies: ["TEXT"],
547
578
  struct: true,
548
579
  });
549
- f.on("message", (msg) => {
550
- msg.once("attributes", (att) => {
580
+ f.on("message", msg => {
581
+ msg.once("attributes", att => {
551
582
  attrs = att;
552
583
  });
553
- msg.on("body", async (stream) => {
584
+ msg.on("body", async stream => {
554
585
  header_mail = stream;
555
586
  stream.resume();
556
587
  });
@@ -571,14 +602,14 @@ module.exports = {
571
602
  this.all_seqno[client].push(seqno);
572
603
  this.all_seqno[client].sort((a, b) => b - a);
573
604
  let new_attrs;
574
- next_msg.once("attributes", (att) => {
605
+ next_msg.once("attributes", att => {
575
606
  new_attrs = att;
576
607
  });
577
608
  next_msg.on("body", async (stream, info) => {
578
609
  let mail;
579
610
  try {
580
611
  mail = await simpleParser(stream, this.clientsRaw[client].node_option);
581
- } catch (e) {
612
+ } catch {
582
613
  mail = this.current_date(client);
583
614
  }
584
615
  const att = {
@@ -589,7 +620,7 @@ module.exports = {
589
620
  let mail_header;
590
621
  try {
591
622
  mail_header = await simpleParser(header_mail, this.clientsRaw[client].node_option);
592
- } catch (e) {
623
+ } catch {
593
624
  mail_header = this.current_date(client);
594
625
  }
595
626
  mail.text = mail_header.text;
@@ -598,18 +629,20 @@ module.exports = {
598
629
  }
599
630
  mail.attachments = all_att.attach;
600
631
  mail.attachments_info = all_att.attach_info;
601
- if (mail.headerLines) mail.headerLines = [];
632
+ if (mail.headerLines) {
633
+ mail.headerLines = [];
634
+ }
602
635
  this.updatejson(mail, seqno, att, info, client, what);
603
636
  stream.resume();
604
637
  });
605
638
  });
606
- e.once("error", (error) => {
639
+ e.once("error", error => {
607
640
  if (error) {
608
641
  this.log_translator("error", "Error", client, error);
609
642
  }
610
643
  });
611
644
  });
612
- f.once("error", (error) => {
645
+ f.once("error", error => {
613
646
  if (error) {
614
647
  this.log_translator("error", "Error", client, error);
615
648
  }
@@ -624,7 +657,7 @@ module.exports = {
624
657
  */
625
658
  diffArray(arr1, arr2, from, client) {
626
659
  try {
627
- const diff = (a, b) => a.filter((item) => b.indexOf(item) === -1);
660
+ const diff = (a, b) => a.filter(item => b.indexOf(item) === -1);
628
661
  if (from === 1) {
629
662
  return diff(arr1, arr2);
630
663
  }
@@ -634,7 +667,7 @@ module.exports = {
634
667
  const diff1 = diff(arr1, arr2);
635
668
  const diff2 = diff(arr2, arr1);
636
669
  return [].concat(diff1, diff2);
637
- } catch (e) {
670
+ } catch {
638
671
  this.log_translator(
639
672
  "warn",
640
673
  "Error",
@@ -653,7 +686,7 @@ module.exports = {
653
686
  if (sort) {
654
687
  this.all_seqno[client] = seqno;
655
688
  } else {
656
- const isRange = this.all_seqno[client].findIndex((number) => number == seqno);
689
+ const isRange = this.all_seqno[client].findIndex(number => number == seqno);
657
690
  if (isRange != -1) {
658
691
  this.all_seqno[client][isRange] = seqno;
659
692
  }
@@ -661,12 +694,13 @@ module.exports = {
661
694
  },
662
695
  /**
663
696
  * Event when message metadata (e.g. flags) changes externally
697
+ *
664
698
  * @param {number} seqno
665
699
  * @param {object} info
666
700
  * @param {string} client device id
667
701
  */
668
702
  onUpdate(seqno, info, client) {
669
- const isRange = this.all_seqno[client].findIndex((number) => number == seqno);
703
+ const isRange = this.all_seqno[client].findIndex(number => number == seqno);
670
704
  if (isRange != -1 && (isRange < this.clientsRaw[client].max || isRange == this.clientsRaw[client].max)) {
671
705
  this.log_translator("info", "Start Update", seqno, client, JSON.stringify(info));
672
706
  info["seqno"] = seqno;
@@ -676,12 +710,30 @@ module.exports = {
676
710
  this.log_translator("info", "No Update", seqno, client, JSON.stringify(info));
677
711
  }
678
712
  this.setTotal(client, this.clientsRaw[client].inbox_activ);
713
+ this.updateTotal(client, this.clientsRaw[client].inbox_activ);
714
+ },
715
+ /**
716
+ * Update eMails total
717
+ *
718
+ * @param {string} client device id
719
+ * @param {string} folder actual inbox
720
+ */
721
+ async updateTotal(client, folder) {
722
+ this.totalTimeout[client] && this.clearTimeout(this.totalTimeout[client]);
723
+ this.totalTimeout[client] = null;
724
+ this.totalTimeout[client] = this.setTimeout(async () => {
725
+ const all_mail = await this.loadAllSeqno(client, folder, true);
726
+ await this.setState(`${client}.total`, {
727
+ val: typeof all_mail === "object" ? all_mail.length : 0,
728
+ ack: true,
729
+ });
730
+ }, 5 * 1000);
679
731
  },
680
732
  /**
681
733
  * @param {object} attrs
682
734
  */
683
735
  async updateattachments(attrs) {
684
- return new Promise((resolve) => {
736
+ return new Promise(resolve => {
685
737
  const all_att = [];
686
738
  let counter_att = 0;
687
739
  if (attrs && attrs.struct) {
@@ -746,11 +798,11 @@ module.exports = {
746
798
  bodies: ["TEXT"],
747
799
  struct: true,
748
800
  });
749
- f.on("message", (msg) => {
750
- msg.once("attributes", (att) => {
801
+ f.on("message", msg => {
802
+ msg.once("attributes", att => {
751
803
  attrs = att;
752
804
  });
753
- msg.on("body", async (stream) => {
805
+ msg.on("body", async stream => {
754
806
  header_mail = stream;
755
807
  stream.resume();
756
808
  });
@@ -768,14 +820,14 @@ module.exports = {
768
820
  });
769
821
  e.on("message", (next_msg, seqno) => {
770
822
  let new_attrs;
771
- next_msg.once("attributes", (att) => {
823
+ next_msg.once("attributes", att => {
772
824
  new_attrs = att;
773
825
  });
774
826
  next_msg.on("body", async (stream, info) => {
775
827
  let mail;
776
828
  try {
777
829
  mail = await simpleParser(stream, this.clientsRaw[client].node_option);
778
- } catch (e) {
830
+ } catch {
779
831
  mail = this.current_date(client);
780
832
  }
781
833
  const att = {
@@ -786,7 +838,7 @@ module.exports = {
786
838
  let mail_header;
787
839
  try {
788
840
  mail_header = await simpleParser(header_mail, this.clientsRaw[client].node_option);
789
- } catch (e) {
841
+ } catch {
790
842
  mail_header = this.current_date(client);
791
843
  }
792
844
  mail.text = mail_header.text;
@@ -795,18 +847,20 @@ module.exports = {
795
847
  }
796
848
  mail.attachments = all_att.attach;
797
849
  mail.attachments_info = all_att.attach_info;
798
- if (mail.headerLines) mail.headerLines = [];
850
+ if (mail.headerLines) {
851
+ mail.headerLines = [];
852
+ }
799
853
  this.updatejson(mail, seqno, att, info, client, what);
800
854
  stream.resume();
801
855
  });
802
856
  });
803
- e.once("error", (error) => {
857
+ e.once("error", error => {
804
858
  if (error) {
805
859
  this.log_translator("error", "Error", client, error);
806
860
  }
807
861
  });
808
862
  });
809
- f.once("error", (error) => {
863
+ f.once("error", error => {
810
864
  if (error) {
811
865
  this.log_translator("error", "Error", client, error);
812
866
  }
@@ -815,8 +869,64 @@ module.exports = {
815
869
  this.log_translator("error", "Error", client, error);
816
870
  }
817
871
  },
872
+ /**
873
+ * @param {string} client device id
874
+ * @param {string} folder
875
+ */
876
+ addBox(client, folder) {
877
+ if (!folder || folder == "") {
878
+ return;
879
+ }
880
+ this.clients[client].addBox(folder, err => {
881
+ if (!err) {
882
+ this.log_translator("info", "addBox", `addBox ${folder} success`, client);
883
+ this.setFolder(client);
884
+ } else {
885
+ this.log_translator("error", "Error", client, err);
886
+ }
887
+ });
888
+ },
889
+ /**
890
+ * @param {string} client device id
891
+ * @param {string} folder
892
+ */
893
+ deleteBox(client, folder) {
894
+ if (!folder || folder == "") {
895
+ return;
896
+ }
897
+ this.clients[client].delBox(folder, err => {
898
+ if (!err) {
899
+ this.log_translator("info", "delBox", `deleteBox ${folder} success`, client);
900
+ this.setFolder(client);
901
+ } else {
902
+ this.log_translator("error", "Error", client, err);
903
+ }
904
+ });
905
+ },
906
+ /**
907
+ * @param {string} client device id
908
+ * @param {string} oldname
909
+ * @param {string} newname
910
+ */
911
+ rename(client, oldname, newname) {
912
+ if (!oldname || oldname == "") {
913
+ return;
914
+ }
915
+ if (!newname || newname == "") {
916
+ return;
917
+ }
918
+ this.clients[client].renameBox(oldname, newname, err => {
919
+ if (!err) {
920
+ this.log_translator("info", "renameBox", `renameBox ${oldname} with ${newname} success`, client);
921
+ this.setFolder(client);
922
+ } else {
923
+ this.log_translator("error", "Error", client, err);
924
+ }
925
+ });
926
+ },
818
927
  /**
819
928
  * set, add, del: Flags, Labels, Keyword, move or copy
929
+ *
820
930
  * @param {string} client device id
821
931
  * @param {string} event
822
932
  * @param {number|object} uid
@@ -824,7 +934,7 @@ module.exports = {
824
934
  */
825
935
  change_events(client, event, uid, flags) {
826
936
  try {
827
- this.clients[client][event](uid, flags, (err) => {
937
+ this.clients[client][event](uid, flags, err => {
828
938
  if (!err) {
829
939
  this.log_translator(
830
940
  "info",
@@ -842,10 +952,12 @@ module.exports = {
842
952
  },
843
953
  /**
844
954
  * @param {string} client device id
845
- * @param {any} folder
955
+ * @param {string} folder Folder Name
846
956
  */
847
957
  changeFolder(client, folder) {
848
- if (folder == this.clientsRaw[client].inbox_activ) return;
958
+ if (folder == this.clientsRaw[client].inbox_activ) {
959
+ return;
960
+ }
849
961
  if (folder && folder != "") {
850
962
  this.clientsRaw[client].inbox_activ = folder;
851
963
  this.getStatus(folder, client);
@@ -862,7 +974,7 @@ module.exports = {
862
974
  val: JSON.stringify(mailbox),
863
975
  ack: true,
864
976
  });
865
- await this.loadAllSeqno(client, this.clientsRaw[client].inbox_activ);
977
+ await this.loadAllSeqno(client, this.clientsRaw[client].inbox_activ, false);
866
978
  if (this.clients[client].serverSupports("SORT")) {
867
979
  this.readMailsSort(client);
868
980
  } else {
@@ -885,7 +997,7 @@ module.exports = {
885
997
  val: JSON.stringify(mailbox),
886
998
  ack: true,
887
999
  });
888
- await this.loadAllSeqno(client, this.clientsRaw[client].inbox_activ);
1000
+ await this.loadAllSeqno(client, this.clientsRaw[client].inbox_activ, false);
889
1001
  if (this.clients[client].serverSupports("SORT")) {
890
1002
  this.readMailsSort(client);
891
1003
  } else {
@@ -897,9 +1009,10 @@ module.exports = {
897
1009
  },
898
1010
  /**
899
1011
  *
1012
+ * @param {string} client
900
1013
  */
901
1014
  loadUnseenSeqno(client) {
902
- return new Promise((resolve) => {
1015
+ return new Promise(resolve => {
903
1016
  this.clients[client].search(["UNSEEN"], async (error, results) => {
904
1017
  if (error) {
905
1018
  this.emit("error", error, this.client);
@@ -911,6 +1024,7 @@ module.exports = {
911
1024
  },
912
1025
  /**
913
1026
  * Blockly Call
1027
+ *
914
1028
  * @param {string} client device id
915
1029
  * @param {object} obj
916
1030
  */
@@ -964,6 +1078,7 @@ module.exports = {
964
1078
  },
965
1079
  /**
966
1080
  * Blockly Call from message event
1081
+ *
967
1082
  * @param {string} client device id
968
1083
  * @param {number|object} read_mail
969
1084
  * @param {object} obj
@@ -987,7 +1102,7 @@ module.exports = {
987
1102
  readAllMails(client, result, obj, count) {
988
1103
  const all_mails = [];
989
1104
  let counter = 0;
990
- return new Promise((resolve) => {
1105
+ return new Promise(resolve => {
991
1106
  try {
992
1107
  const f = this.clients[client].fetch(result, {
993
1108
  bodies: "",
@@ -995,7 +1110,7 @@ module.exports = {
995
1110
  });
996
1111
  f.on("message", (msg, seqno) => {
997
1112
  let attrs;
998
- msg.on("attributes", (att) => {
1113
+ msg.on("attributes", att => {
999
1114
  attrs = att;
1000
1115
  });
1001
1116
  msg.on("body", async (stream, info) => {
@@ -1017,7 +1132,7 @@ module.exports = {
1017
1132
  }
1018
1133
  });
1019
1134
  });
1020
- f.once("error", (error) => {
1135
+ f.once("error", error => {
1021
1136
  if (error) {
1022
1137
  this.log_translator("error", "Error", client, error);
1023
1138
  }