iobroker.imap 0.1.2 → 0.2.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/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "imap",
4
- "version": "0.1.2",
4
+ "version": "0.2.0",
5
5
  "news": {
6
+ "0.2.0": {
7
+ "en": "Updated Blockly definitions\nJS-Controller >= 5.0.19 required\nAdmin >=6.13.16 required",
8
+ "de": "Aktualisierte Blockly Definitionen\nJS-Controller >= 5.0.19 erforderlich\nAdmin >=6.13.16 erforderlich",
9
+ "ru": "Обновленные детальные определения\n JS 5.0.19\n>=6.13.16",
10
+ "pt": "Definições Blockly atualizadas\nJS-Controller >= 5.0.19 necessário\nAdmin >=6.13.16 necessário",
11
+ "nl": "Bijgewerkte blokdefinities\nJS-Controller < 5.01.19 vereist\nAdmin < 6.13.16 vereist",
12
+ "fr": "Mise à jour des définitions par blocs\nJS-Contrôleur >= 5.0.19 requis\nAdmin >=6.13.16 requis",
13
+ "it": "Aggiornate definizioni Blockly\nJS-Controller >= 5.0.19 richiesto\nAdmin >=6.13.16 richiesto",
14
+ "es": "Definiciones bloqueadas actualizadas\nJS-Controller ≤ 5.0.19 requerido\nPersonal obligatorio",
15
+ "pl": "Aktualizacja definicji blockly\nJS- Controller > = 5.0.19 wymagane\nWymagany dodatek > = 6.13.16",
16
+ "uk": "Оновлено блочні визначення\nJS-Controller >=5.0.19 потрібно\nAdmin >=6.13.16 потрібно",
17
+ "zh-cn": "更新的块状定义\n联合来文主计长\n所需行政经费"
18
+ },
19
+ "0.1.3": {
20
+ "en": "Fixed setFlag\nFixed sendTo error during instance deletion ([#57](https://github.com/Lucky-ESA/ioBroker.imap/issues/57))\nMass email shift intercepted",
21
+ "de": "Fixed set Flagge\nFester Versand Fehler bei der Löschung von Instanzen ([#57](https://github.com/Lucky-ESA/ioBroker.imap/issues/57))\nMassen-E-Mail-Schicht abgefangen",
22
+ "ru": "Фиксированный набор Флаг\nFixed send Ошибка во время удаления ([#57] (https://github.com/Lucky-ESA/ioBroker.imap/issues/57))\nМассовый смещение электронной почты перехвачено",
23
+ "pt": "Conjunto fixo Bandeira\nEnviar fixo Para erro durante a exclusão de instância ([#57](https://github.com/Lucky-ESA/ioBroker.imap/issues/57))\nMudança de e-mail em massa interceptada",
24
+ "nl": "Vaste set Vlag\nVaste verzending Fout tijdens het verwijderen van instantie ([#57](https://github.com/Lucky-ESA/ioBroker.imap/issues/57))\nOnderschepte massa-e-mailverschuiving",
25
+ "fr": "Set fixe Drapeau\nEnvoi fixe Erreur lors de la suppression de l'instance ([#57](https://github.com/Lucky-ESA/ioBroker.imap/issues/57)\nChangement d'email de masse intercepté",
26
+ "it": "Set fisso Bandiera\nInviato fisso Per errore durante la cancellazione delle istanze ([#57](https://github.com/Lucky-ESA/ioBroker.imap/issues/57))\nSpostamento email di massa intercettato",
27
+ "es": "Juego fijo Bandera\nEnvío fijo To error during instance deletion ([#57](https://github.com/Lucky-ESA/ioBroker.imap/issues/57))\nCambio de correo electrónico interceptado",
28
+ "pl": "Zestaw stały Flaga\nPoprawiono wysyłanie Do błędu podczas usuwania instancji ([# 57] (https: / / github.com / Lucky- ESA / ioBroker.imap / issues / 57))\nMass email przesunięcie przechwycone",
29
+ "uk": "Фіксований набір Прапор\nВиправлена відправка Помилки ([#57](https://github.com/Lucky-ESA/ioBroker.imap/issues/57))\nМасова зміна електронної пошти",
30
+ "zh-cn": "固定设备 旗帜\n固定发送 删除实例时出现错误([#57](https://github.com/Lucky-ESA/ioBroker.imap/issues/57))\n已截取大宗电子邮件"
31
+ },
6
32
  "0.1.2": {
7
33
  "en": "Added missing translate\nUpdated package\nBug fixes",
8
34
  "de": "Hinzugefügt fehlende Übersetzung\nAktualisiertes Paket\nFehlerbehebungen",
@@ -67,32 +93,6 @@
67
93
  "pl": "Fixel crash\nAdded MB progym",
68
94
  "uk": "Виправлення аварійних змін\nДодано поріг MB",
69
95
  "zh-cn": "Fixtifresh c\nA. 增加MB门槛"
70
- },
71
- "0.0.7": {
72
- "en": "Fix correct counter for seen and unseen\nAdded capabilities\nCriteria change without restart\nAdded outlook.office365.com oauth2 login\nAdded Connection.js from Module to Adapter\nBug fixes",
73
- "de": "Fix korrekter Zähler für gesehen und unsichtbar\nZusätzliche Fähigkeiten\nÄnderung der Kriterien ohne Neustart\nAusblick.office365.com oauth2 login\nHinzugefügt Connection.js von Modul zu Adapter\nFehlerbehebungen",
74
- "ru": "Исправьте правильный счетчик для видимых и невидимых\nДобавленные возможности\nКритерии меняются без перезапуска\nДобавлен Outlook.office365.com oauth2 логин\nДобавлено Connection.js из модуля к адаптеру\nИсправления ошибок",
75
- "pt": "Corrigir o contador correto para visto e invisível\nRecursos adicionados\nAlteração de critérios sem reinício\nAdicionado outlook.office365.com oauth2 login\nAdicionado Connection.js do módulo ao adaptador\nCorreções de bugs",
76
- "nl": "Vertaling:\nVermogens\nCriteria verandert zonder rust\nVertaling:\nToegevoegd Connection\nBug repareert",
77
- "fr": "Fixer le compteur correct pour vu et invisible\nCapacités ajoutées\nChangement de critères sans redémarrage\nAjout du login Outlook.office365.com oauth2\nAjout de Connection.js de Module à Adaptateur\nCorrections",
78
- "it": "Fissare corretto contatore per visto e invisibile\nCapacità aggiuntive\nCambiamento dei criteri senza riavvio\nAggiunto Outlook.office365.com oauth2 login\nAggiunto Connection.js dal modulo all'adattatore\nCorrezioni di bug",
79
- "es": "Fijar el contador correcto para visto y no visto\nCapacidades adicionales\nLos criterios cambian sin reiniciar\nAñadido Outlook.office365.com oauth2 login\nAñadido Connection.js del módulo al adaptador\nCorrección de errores",
80
- "pl": "Fix koryguje pole widzenia i niespodzianek\nZadaniowe możliwości\nPrzemiana kryzysowa bez restartu\nAdded outlook.office365.com oauth2 login\nAdded Connection.js from Module to Adapter\nBug",
81
- "uk": "Фіксувати правильну лічильник для видимих і невидимих\nДодаткові можливості\nЗміни критерії без перезапуску\nEnglish, Українська, Français..\nДодано Connection.js від Module до адаптера\nВиправлення помилок",
82
- "zh-cn": "Fix 纠正被发现和无见的反击\n增加能力\n2. 标准改变,而不恢复原状\n增加前景\nA. 添加了Anection.js from Module to Adapter\nBug fix"
83
- },
84
- "0.0.6": {
85
- "en": "Added trigger move or copy emails\nAdded JSON for multiple IMAP accounts\nBug fixes",
86
- "de": "Trigger-Bewegung oder Kopie-E-Mails hinzugefügt\nJSON für mehrere IMAP-Konten hinzugefügt\nFehlerbehebungen",
87
- "ru": "Добавлены триггеры или копировать электронные письма\nДобавлен JSON для нескольких учетных записей IMAP\nИсправления ошибок",
88
- "pt": "Adicionado movimento do gatilho ou copiar e-mails\nAdicionado JSON para múltiplas contas IMAP\nCorreções de bugs",
89
- "nl": "Verplaatsing of mails\n_\nBug repareert",
90
- "fr": "Ajout d'un déménagement ou d'une copie des courriels\nJSON ajouté pour plusieurs comptes IMAP\nCorrections",
91
- "it": "Aggiunta di attivazione spostare o copiare e-mail\nAggiunto JSON per più account IMAP\nCorrezioni di bug",
92
- "es": "Añadido movimiento de gatillo o copiar correos electrónicos\nAñadido JSON para múltiples cuentas de IMAP\nCorrección de errores",
93
- "pl": "Added trigger move lub copy mail\nAdded JSON dla wielu kont IMAP\nBug",
94
- "uk": "Доданий тригер переміщення або копіювання електронних листів\nДодано JSON для декількох облікових записів IMAP\nВиправлення помилок",
95
- "zh-cn": "增购机或邮票\n增聘联合办多管方案账户\nBug fix"
96
96
  }
97
97
  },
98
98
  "titleLang": {
@@ -130,9 +130,12 @@
130
130
  "email",
131
131
  "receive"
132
132
  ],
133
- "license": "MIT",
133
+ "licenseInformation": {
134
+ "license": "MIT",
135
+ "type": "free"
136
+ },
137
+ "tier": 3,
134
138
  "platform": "Javascript/Node.js",
135
- "main": "main.js",
136
139
  "icon": "imap.png",
137
140
  "enabled": true,
138
141
  "extIcon": "https://raw.githubusercontent.com/Lucky-ESA/ioBroker.imap/master/admin/imap.png",
@@ -158,12 +161,12 @@
158
161
  },
159
162
  "dependencies": [
160
163
  {
161
- "js-controller": ">=3.3.22"
164
+ "js-controller": ">=5.0.19"
162
165
  }
163
166
  ],
164
167
  "globalDependencies": [
165
168
  {
166
- "admin": ">=5.1.13"
169
+ "admin": ">=6.13.16"
167
170
  }
168
171
  ]
169
172
  },
package/lib/Connection.js CHANGED
@@ -208,7 +208,8 @@ class Connection extends EventEmitter {
208
208
  // because 'HEADER.FIELDS (TO FROM)' really is equivalent to
209
209
  // 'HEADER.FIELDS ("TO" "FROM")' and some servers will actually send the
210
210
  // quoted form even if the client did not use quotes
211
- const thisbody = parseExpr(info.which.toUpperCase());
211
+
212
+ const thisbody = info.which != null ? parseExpr(info.which.toUpperCase()) : "";
212
213
  for (let i = 0, len = toget.length; i < len; ++i) {
213
214
  if (deepEqual(thisbody, toget[i])) {
214
215
  toget.splice(i, 1);
@@ -728,8 +729,8 @@ class Connection extends EventEmitter {
728
729
  const req = this._queue !== undefined ? this._queue[this._queue.length - 1] : 0;
729
730
  req.fetchCache = {};
730
731
  req.fetching = fetching;
731
- this.debug("FETCH: " + JSON.stringify(fetching));
732
- this.debug("CMD: " + cmd);
732
+ this.debug && this.debug("FETCH: " + JSON.stringify(fetching));
733
+ this.debug && this.debug("CMD: " + cmd);
733
734
  return (req.bodyEmitter = new EventEmitter());
734
735
  }
735
736
  // Extension methods ===========================================================
@@ -1092,12 +1093,15 @@ class Connection extends EventEmitter {
1092
1093
  this._curReq.cbargs.push(box);
1093
1094
  } else if (type === "fetch") {
1094
1095
  if (this._curReq && this._curReq.fullcmd) {
1095
- this.debug("this._curReq.fullcmd: " + this._curReq.fullcmd);
1096
+ this.debug && this.debug("this._curReq.fullcmd: " + this._curReq.fullcmd);
1096
1097
  }
1097
- this.debug("infos: " + JSON.stringify(info));
1098
+ this.debug && this.debug("infos: " + JSON.stringify(info));
1098
1099
  if (this._curReq && this._curReq.fullcmd != null && /^(?:UID )?FETCH/.test(this._curReq.fullcmd)) {
1099
- this.debug("this._curReq.fullcmd: " + this._curReq.fullcmd);
1100
- this.debug("this._curReq.fetchCache[info.num]: " + this._curReq.fetchCache[info.num]);
1100
+ this.debug && this.debug("this._curReq.fullcmd: " + this._curReq.fullcmd);
1101
+ this.debug &&
1102
+ this.debug(
1103
+ "this._curReq.fetchCache[info.num]: " + JSON.stringify(this._curReq.fetchCache[info.num]),
1104
+ );
1101
1105
  // FETCH response sent as result of FETCH request
1102
1106
  const msg = this._curReq.fetchCache[info.num];
1103
1107
  const keys = Object.keys(info.text);
package/lib/imap_event.js CHANGED
@@ -296,16 +296,41 @@ module.exports = {
296
296
  const isRange = this.all_seqno[client].findIndex((number) => number == seqno);
297
297
  if (isRange != -1 && (isRange < this.clientsRaw[client].max || isRange == this.clientsRaw[client].max)) {
298
298
  this.log_translator("info", "EMail deleted in scope", client, seqno);
299
- if (this.clients[client].serverSupports("SORT")) {
300
- this.readMailsSort(client);
301
- } else {
302
- this.readMails(client);
303
- }
299
+ this.clientsRaw[client].isonExpunge = true;
304
300
  } else {
305
301
  this.log_translator("info", "EMail deleted", client, seqno);
306
302
  }
307
- this.setUpdate(client, { seqno: seqno }, "move_copy");
308
- this.setTotal(client, this.clientsRaw[client].inbox_activ);
303
+ this.clientsRaw[client].seqonExpunge.push(seqno);
304
+ if (this.clientsRaw[client].onExpungeTimer) {
305
+ this.clearTimeout(this.clientsRaw[client].onExpungeTimer);
306
+ this.clientsRaw[client].onExpungeTimer = null;
307
+ ++this.clientsRaw[client].onExpunge;
308
+ }
309
+ this.clientsRaw[client].onExpungeTimer = this.setTimeout(() => {
310
+ if (this.clientsRaw[client].onExpunge > 1) {
311
+ if (this.clientsRaw[client].isonExpunge) {
312
+ if (this.clients[client].serverSupports("SORT")) {
313
+ this.readMailsSort(client);
314
+ } else {
315
+ this.readMails(client);
316
+ }
317
+ }
318
+ this.setUpdate(client, { seqno: this.clientsRaw[client].seqonExpunge }, "move_copy");
319
+ } else {
320
+ if (this.clientsRaw[client].isonExpunge) {
321
+ if (this.clients[client].serverSupports("SORT")) {
322
+ this.readMailsSort(client);
323
+ } else {
324
+ this.readMails(client);
325
+ }
326
+ this.setUpdate(client, { seqno: seqno }, "move_copy");
327
+ }
328
+ }
329
+ this.clientsRaw[client].seqonExpunge = [];
330
+ this.setTotal(client, this.clientsRaw[client].inbox_activ);
331
+ this.clientsRaw[client].onExpunge = 0;
332
+ this.clientsRaw[client].isonExpunge = false;
333
+ }, 1000);
309
334
  },
310
335
  /**
311
336
  * Event if UIDs in this mailbox have changed since the last time this mailbox was opened.
package/main.js CHANGED
@@ -223,6 +223,10 @@ class Imap extends utils.Adapter {
223
223
  await this.cleanupDatapoints(dev);
224
224
  continue;
225
225
  }
226
+ dev.onExpunge = 0;
227
+ dev.seqonExpunge = [];
228
+ dev.isonExpunge = false;
229
+ dev.onExpungeTimer = null;
226
230
  this.clientsHTML[dev.user] = {};
227
231
  this.boxfolder[dev.user] = {};
228
232
  this.restartIMAPConnection[dev.user] = null;
@@ -1185,12 +1189,14 @@ class Imap extends utils.Adapter {
1185
1189
  onUnload(callback) {
1186
1190
  try {
1187
1191
  for (const dev of this.clientsID) {
1192
+ this.clientsRaw[dev].onExpungeTimer && this.clearTimeout(this.clientsRaw[dev].onExpungeTimer);
1188
1193
  this.clients[dev] = null;
1189
1194
  this.restartIMAPConnection[dev] && this.clearTimeout(this.restartIMAPConnection[dev]);
1190
1195
  this.setState(`${dev}.online`, {
1191
1196
  val: false,
1192
1197
  ack: true,
1193
1198
  });
1199
+ this.clientsRaw[dev] = null;
1194
1200
  }
1195
1201
  this.qualityInterval && this.clearInterval(this.qualityInterval);
1196
1202
  this.statusInterval && this.clearInterval(this.statusInterval);
@@ -1278,6 +1284,14 @@ class Imap extends utils.Adapter {
1278
1284
  this.setAckFlag(id);
1279
1285
  return;
1280
1286
  }
1287
+ if (command === "set") {
1288
+ this.setAckFlag(id);
1289
+ return;
1290
+ }
1291
+ if (command === "type") {
1292
+ this.setAckFlag(id);
1293
+ return;
1294
+ }
1281
1295
  if (command === "folder") {
1282
1296
  this.setAckFlag(id);
1283
1297
  return;
@@ -1401,15 +1415,15 @@ class Imap extends utils.Adapter {
1401
1415
  */
1402
1416
  async applyFlag(clientID, set, uid, type) {
1403
1417
  if (this.clients[clientID]) {
1404
- if (set == "") {
1418
+ if (set == "" || set == null) {
1405
1419
  const sets = await this.getStateAsync(`${clientID}.remote.flag.set`);
1406
1420
  set = sets && sets.val ? sets.val.toString() : "";
1407
1421
  }
1408
- if (uid === 0) {
1422
+ if (uid === 0 || uid == null) {
1409
1423
  const uids = await this.getStateAsync(`${clientID}.remote.flag.uid`);
1410
1424
  uid = uids && uids.val != null ? Number(uids.val) : 0;
1411
1425
  }
1412
- if (type == "") {
1426
+ if (type == "" || type == null) {
1413
1427
  const types = await this.getStateAsync(`${clientID}.remote.flag.type`);
1414
1428
  type = types && types.val ? types.val.toString() : "";
1415
1429
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.imap",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "imap to receive your emails",
5
5
  "author": {
6
6
  "name": "Lucky-ESA",
@@ -19,40 +19,40 @@
19
19
  "url": "git@github.com:Lucky-ESA/ioBroker.imap.git"
20
20
  },
21
21
  "engines": {
22
- "node": ">= 16"
22
+ "node": ">= 18"
23
23
  },
24
24
  "dependencies": {
25
- "@iobroker/adapter-core": "^3.0.4",
26
- "mailparser": "^3.6.5",
25
+ "@iobroker/adapter-core": "^3.1.6",
26
+ "mailparser": "^3.7.1",
27
27
  "node-imap": "^0.9.6"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@alcalzone/release-script": "^3.7.0",
31
- "@alcalzone/release-script-plugin-iobroker": "^3.7.0",
31
+ "@alcalzone/release-script-plugin-iobroker": "^3.7.1",
32
32
  "@alcalzone/release-script-plugin-license": "^3.7.0",
33
33
  "@alcalzone/release-script-plugin-manual-review": "^3.7.0",
34
- "@iobroker/adapter-dev": "^1.2.0",
35
- "@iobroker/testing": "^4.1.0",
36
- "@tsconfig/node16": "^16.1.1",
37
- "@types/chai": "^4.3.11",
34
+ "@iobroker/adapter-dev": "^1.3.0",
35
+ "@iobroker/testing": "^4.1.3",
36
+ "@tsconfig/node18": "^18.2.4",
37
+ "@types/chai": "^4.3.16",
38
38
  "@types/chai-as-promised": "^7.1.8",
39
39
  "@types/imap": "^0.8.40",
40
40
  "@types/mocha": "^10.0.6",
41
- "@types/node": "^20.10.6",
41
+ "@types/node": "^20.14.2",
42
42
  "@types/proxyquire": "^1.3.31",
43
- "@types/sinon": "^17.0.2",
43
+ "@types/sinon": "^17.0.3",
44
44
  "@types/sinon-chai": "^3.2.12",
45
- "chai": "^4.3.10",
46
- "chai-as-promised": "^7.1.1",
47
- "eslint": "^8.56.0",
45
+ "chai": "^4.4.1",
46
+ "chai-as-promised": "^7.1.2",
47
+ "eslint": "^8.57.0",
48
48
  "eslint-config-prettier": "^9.1.0",
49
- "eslint-plugin-prettier": "^5.1.2",
50
- "mocha": "^10.2.0",
51
- "prettier": "^3.1.1",
49
+ "eslint-plugin-prettier": "^5.1.3",
50
+ "mocha": "^10.4.0",
51
+ "prettier": "^3.3.2",
52
52
  "proxyquire": "^2.1.3",
53
- "sinon": "^17.0.1",
53
+ "sinon": "^18.0.0",
54
54
  "sinon-chai": "^3.7.0",
55
- "typescript": "~5.3.2"
55
+ "typescript": "~5.4.5"
56
56
  },
57
57
  "main": "main.js",
58
58
  "files": [