Skip to content

Commit

Permalink
Mass email shift intercepted
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucky-ESA committed Mar 6, 2024
1 parent e6162c4 commit f027f12
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -61,6 +61,7 @@

- (Lucky-ESA) Fixed setFlag
- (Lucky-ESA) Fixed sendTo error during instance deletion ([#57](https://github.com/Lucky-ESA/ioBroker.imap/issues/57))
- (Lucky-ESA) Mass email shift intercepted

### 0.1.2 (2024-01-24)

Expand Down
39 changes: 32 additions & 7 deletions lib/imap_event.js
Expand Up @@ -296,16 +296,41 @@ module.exports = {
const isRange = this.all_seqno[client].findIndex((number) => number == seqno);
if (isRange != -1 && (isRange < this.clientsRaw[client].max || isRange == this.clientsRaw[client].max)) {
this.log_translator("info", "EMail deleted in scope", client, seqno);
if (this.clients[client].serverSupports("SORT")) {
this.readMailsSort(client);
} else {
this.readMails(client);
}
this.clientsRaw[client].isonExpunge = true;
} else {
this.log_translator("info", "EMail deleted", client, seqno);
}
this.setUpdate(client, { seqno: seqno }, "move_copy");
this.setTotal(client, this.clientsRaw[client].inbox_activ);
this.clientsRaw[client].seqonExpunge.push(seqno);
if (this.clientsRaw[client].onExpungeTimer) {
this.clearTimeout(this.clientsRaw[client].onExpungeTimer);
this.clientsRaw[client].onExpungeTimer = null;
++this.clientsRaw[client].onExpunge;
}
this.clientsRaw[client].onExpungeTimer = this.setTimeout(() => {
if (this.clientsRaw[client].onExpunge > 1) {
if (this.clientsRaw[client].isonExpunge) {
if (this.clients[client].serverSupports("SORT")) {
this.readMailsSort(client);
} else {
this.readMails(client);
}
}
this.setUpdate(client, { seqno: this.clientsRaw[client].seqonExpunge }, "move_copy");
} else {
if (this.clientsRaw[client].isonExpunge) {
if (this.clients[client].serverSupports("SORT")) {
this.readMailsSort(client);
} else {
this.readMails(client);
}
this.setUpdate(client, { seqno: seqno }, "move_copy");
}
}
this.clientsRaw[client].seqonExpunge = [];
this.setTotal(client, this.clientsRaw[client].inbox_activ);
this.clientsRaw[client].onExpunge = 0;
this.clientsRaw[client].isonExpunge = false;
}, 1000);
},
/**
* Event if UIDs in this mailbox have changed since the last time this mailbox was opened.
Expand Down
6 changes: 6 additions & 0 deletions main.js
Expand Up @@ -223,6 +223,10 @@ class Imap extends utils.Adapter {
await this.cleanupDatapoints(dev);
continue;
}
dev.onExpunge = 0;
dev.seqonExpunge = [];
dev.isonExpunge = false;
dev.onExpungeTimer = null;
this.clientsHTML[dev.user] = {};
this.boxfolder[dev.user] = {};
this.restartIMAPConnection[dev.user] = null;
Expand Down Expand Up @@ -1185,12 +1189,14 @@ class Imap extends utils.Adapter {
onUnload(callback) {
try {
for (const dev of this.clientsID) {
this.clientsRaw[dev].onExpungeTimer && this.clearTimeout(this.clientsRaw[dev].onExpungeTimer);
this.clients[dev] = null;
this.restartIMAPConnection[dev] && this.clearTimeout(this.restartIMAPConnection[dev]);
this.setState(`${dev}.online`, {
val: false,
ack: true,
});
this.clientsRaw[dev] = null;
}
this.qualityInterval && this.clearInterval(this.qualityInterval);
this.statusInterval && this.clearInterval(this.statusInterval);
Expand Down

0 comments on commit f027f12

Please sign in to comment.