imapflow 1.0.81 → 1.0.82

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ - 1.0.82 - 2022-02-15
4
+
5
+ - Added extra option `expungeHandler`
6
+
3
7
  - 1.0.81 - 2022-02-15
4
8
 
5
9
  - Added support for the QRESYNC extension and untagged VANISHED responses
package/lib/imap-flow.js CHANGED
@@ -942,11 +942,21 @@ class ImapFlow extends EventEmitter {
942
942
  let seq = Number(untagged.command);
943
943
  if (seq && seq <= this.mailbox.exists) {
944
944
  this.mailbox.exists--;
945
- this.emit('expunge', {
945
+ let payload = {
946
946
  path: this.mailbox.path,
947
947
  seq,
948
948
  vanished: false
949
- });
949
+ };
950
+
951
+ if (typeof this.options.expungeHandler === 'function') {
952
+ try {
953
+ await this.options.expungeHandler(payload);
954
+ } catch (err) {
955
+ this.log.error({ msg: 'Failed to notify expunge event', payload, error: err, cid: this.id });
956
+ }
957
+ } else {
958
+ this.emit('expunge', payload);
959
+ }
950
960
  }
951
961
  }
952
962
 
@@ -970,13 +980,24 @@ class ImapFlow extends EventEmitter {
970
980
  }
971
981
 
972
982
  let uidList = expandRange(uids);
983
+
973
984
  for (let uid of uidList) {
974
- this.emit('expunge', {
985
+ let payload = {
975
986
  path: mailbox.path,
976
987
  uid,
977
988
  vanished: true,
978
989
  earlier: tags.includes('EARLIER')
979
- });
990
+ };
991
+
992
+ if (typeof this.options.expungeHandler === 'function') {
993
+ try {
994
+ await this.options.expungeHandler(payload);
995
+ } catch (err) {
996
+ this.log.error({ msg: 'Failed to notify expunge event', payload, error: err, cid: this.id });
997
+ }
998
+ } else {
999
+ this.emit('expunge', payload);
1000
+ }
980
1001
  }
981
1002
  }
982
1003
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "1.0.81",
3
+ "version": "1.0.82",
4
4
  "description": "IMAP Client for Node",
5
5
  "main": "./lib/imap-flow.js",
6
6
  "scripts": {