Comparing version 1.0.148 to 1.0.149
# Changelog | ||
## [1.0.149](https://github.com/postalsys/imapflow/compare/v1.0.148...v1.0.149) (2024-01-31) | ||
### Bug Fixes | ||
* **flag-colors:** added a method to set Flag Color. The color is also included in the Fetch response structure ([d840951](https://github.com/postalsys/imapflow/commit/d8409513075b864e9131665af3f1670a0714d05c)) | ||
## [1.0.148](https://github.com/postalsys/imapflow/compare/v1.0.147...v1.0.148) (2024-01-16) | ||
@@ -4,0 +11,0 @@ |
@@ -11,2 +11,4 @@ /* eslint no-control-regex:0 */ | ||
const FLAG_COLORS = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'grey']; | ||
module.exports = { | ||
@@ -195,2 +197,39 @@ encodePath(connection, path) { | ||
getFlagColor(flags) { | ||
if (!flags.has('\\Flagged')) { | ||
return null; | ||
} | ||
const bit0 = flags.has('$MailFlagBit0') ? 1 : 0; | ||
const bit1 = flags.has('$MailFlagBit1') ? 2 : 0; | ||
const bit2 = flags.has('$MailFlagBit2') ? 4 : 0; | ||
const color = bit0 | bit1 | bit2; // eslint-disable-line no-bitwise | ||
return FLAG_COLORS[color] || 'red'; // default to red for the unused \b111 | ||
}, | ||
getColorFlags(color) { | ||
const colorCode = color ? FLAG_COLORS.indexOf((color || '').toString().toLowerCase().trim()) : null; | ||
if (colorCode < 0 && colorCode !== null) { | ||
return null; | ||
} | ||
const bits = []; | ||
bits[0] = colorCode & 1; // eslint-disable-line no-bitwise | ||
bits[1] = colorCode & 2; // eslint-disable-line no-bitwise | ||
bits[2] = colorCode & 4; // eslint-disable-line no-bitwise | ||
let result = { add: colorCode ? ['\\Flagged'] : [], remove: colorCode ? [] : ['\\Flagged'] }; | ||
for (let i = 0; i < bits.length; i++) { | ||
if (bits[i]) { | ||
result.add.push(`$MailFlagBit${i}`); | ||
} else { | ||
result.remove.push(`$MailFlagBit${i}`); | ||
} | ||
} | ||
return result; | ||
}, | ||
async formatMessageResponse(untagged, mailbox) { | ||
@@ -356,2 +395,9 @@ let map = {}; | ||
if (map.flags) { | ||
let flagColor = module.exports.getFlagColor(map.flags); | ||
if (flagColor) { | ||
map.flagColor = flagColor; | ||
} | ||
} | ||
return map; | ||
@@ -358,0 +404,0 @@ }, |
@@ -368,2 +368,18 @@ /// <reference types="node" /> | ||
/** | ||
* Sets a colored flag for an email. Only supported by mail clients like Apple Mail | ||
* @example | ||
* let mailbox = await client.mailboxOpen('INBOX'); | ||
* // add a purple flag for all emails | ||
* await client.setFlagColor('1:*', 'Purple'); | ||
* @param range - Range to filter the messages | ||
* @param The - color to set. One of 'red', 'orange', 'yellow', 'green', 'blue', 'purple', and 'grey' | ||
* @param [options.uid] - If `true` then uses UID {@link SequenceString} instead of sequence numbers | ||
* @param [options.unchangedSince] - If set then only messages with a lower or equal `modseq` value are updated. Ignored if server does not support `CONDSTORE` extension. | ||
* @returns Did the operation succeed or not | ||
*/ | ||
setFlagColor(range: SequenceString | Number[] | SearchObject, The: string, options?: { | ||
uid?: boolean; | ||
unchangedSince?: bigint; | ||
}): Promise<Boolean>; | ||
/** | ||
* Delete messages from currently opened mailbox. Method does not indicate info about deleted messages, | ||
@@ -836,3 +852,3 @@ * instead you should be using {@link ImapFlow#expunge} event for this | ||
* @property [uid] - if `true` then include UID in the response | ||
* @property [flags] - if `true` then include flags Set in the response | ||
* @property [flags] - if `true` then include flags Set in the response. Also adds `flagColor` to the response if the message is flagged. | ||
* @property [bodyStructure] - if `true` then include parsed BODYSTRUCTURE object in the response | ||
@@ -940,2 +956,3 @@ * @property [envelope] - if `true` then include parsed ENVELOPE object in the response | ||
* @property [flags] - a set of message flags | ||
* @property [flagColor] - flag color like "red", or "yellow". This value is derived from the `flags` Set and it uses the same color rules as Apple Mail | ||
* @property [envelope] - message envelope | ||
@@ -957,2 +974,3 @@ * @property [bodyStructure] - message body structure | ||
flags?: Set<string>; | ||
flagColor?: string; | ||
envelope?: MessageEnvelopeObject; | ||
@@ -959,0 +977,0 @@ bodyStructure?: MessageStructureObject; |
{ | ||
"name": "imapflow", | ||
"version": "1.0.148", | ||
"version": "1.0.149", | ||
"description": "IMAP Client for Node", | ||
@@ -31,10 +31,10 @@ "main": "./lib/imap-flow.js", | ||
"devDependencies": { | ||
"@babel/eslint-parser": "7.22.15", | ||
"@babel/eslint-plugin": "7.22.10", | ||
"@babel/eslint-parser": "7.23.9", | ||
"@babel/eslint-plugin": "7.23.5", | ||
"@babel/plugin-syntax-class-properties": "7.12.13", | ||
"@babel/preset-env": "7.23.2", | ||
"@types/node": "20.8.10", | ||
"eslint": "8.52.0", | ||
"@babel/preset-env": "7.23.9", | ||
"@types/node": "20.11.13", | ||
"eslint": "8.56.0", | ||
"eslint-config-nodemailer": "1.2.0", | ||
"eslint-config-prettier": "9.0.0", | ||
"eslint-config-prettier": "9.1.0", | ||
"grunt": "1.6.1", | ||
@@ -56,6 +56,6 @@ "grunt-cli": "1.4.3", | ||
"mailsplit": "5.4.0", | ||
"nodemailer": "6.9.7", | ||
"pino": "8.16.1", | ||
"nodemailer": "6.9.8", | ||
"pino": "8.17.2", | ||
"socks": "2.7.1" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
572824
71
12570
+ Addednodemailer@6.9.8(transitive)
+ Addedpino@8.17.2(transitive)
+ Addedprocess-warning@3.0.0(transitive)
- Removednodemailer@6.9.7(transitive)
- Removedpino@8.16.1(transitive)
- Removedprocess-warning@2.3.2(transitive)
Updatednodemailer@6.9.8
Updatedpino@8.17.2