mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2026-05-06 17:30:35 +07:00
node_modules: update (#290)
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
52
node_modules/nodemailer/lib/smtp-pool/index.js
generated
vendored
52
node_modules/nodemailer/lib/smtp-pool/index.js
generated
vendored
@@ -51,11 +51,8 @@ class SMTPPool extends EventEmitter {
|
||||
component: this.options.component || 'smtp-pool'
|
||||
});
|
||||
|
||||
// temporary object
|
||||
let connection = new SMTPConnection(this.options);
|
||||
|
||||
this.name = 'SMTP (pool)';
|
||||
this.version = packageData.version + '[client:' + connection.version + ']';
|
||||
this.version = packageData.version + '[client:' + packageData.version + ']';
|
||||
|
||||
this._rateLimit = {
|
||||
counter: 0,
|
||||
@@ -123,7 +120,7 @@ class SMTPPool extends EventEmitter {
|
||||
*/
|
||||
close() {
|
||||
let connection;
|
||||
let len = this._connections.length;
|
||||
const len = this._connections.length;
|
||||
this._closed = true;
|
||||
|
||||
// clear rate limit timer if it exists
|
||||
@@ -164,7 +161,7 @@ class SMTPPool extends EventEmitter {
|
||||
}
|
||||
|
||||
// make sure that entire queue would be cleaned
|
||||
let invokeCallbacks = () => {
|
||||
const invokeCallbacks = () => {
|
||||
if (!this._queue.length) {
|
||||
this.logger.debug(
|
||||
{
|
||||
@@ -174,7 +171,7 @@ class SMTPPool extends EventEmitter {
|
||||
);
|
||||
return;
|
||||
}
|
||||
let entry = this._queue.shift();
|
||||
const entry = this._queue.shift();
|
||||
if (entry && typeof entry.callback === 'function') {
|
||||
try {
|
||||
entry.callback(new Error('Connection pool was closed'));
|
||||
@@ -201,9 +198,6 @@ class SMTPPool extends EventEmitter {
|
||||
* an available connection, then use this connection to send the mail
|
||||
*/
|
||||
_processMessages() {
|
||||
let connection;
|
||||
let i, len;
|
||||
|
||||
// do nothing if already closed
|
||||
if (this._closed) {
|
||||
return;
|
||||
@@ -220,12 +214,7 @@ class SMTPPool extends EventEmitter {
|
||||
}
|
||||
|
||||
// find first available connection
|
||||
for (i = 0, len = this._connections.length; i < len; i++) {
|
||||
if (this._connections[i].available) {
|
||||
connection = this._connections[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
let connection = this._connections.find(c => c.available);
|
||||
|
||||
if (!connection && this._connections.length < this.options.maxConnections) {
|
||||
connection = this._createConnection();
|
||||
@@ -243,7 +232,7 @@ class SMTPPool extends EventEmitter {
|
||||
this.emit('idle');
|
||||
}
|
||||
|
||||
let entry = (connection.queueEntry = this._queue.shift());
|
||||
const entry = (connection.queueEntry = this._queue.shift());
|
||||
entry.messageId = (connection.queueEntry.mail.message.getHeader('message-id') || '').replace(/[<>\s]/g, '');
|
||||
|
||||
connection.available = false;
|
||||
@@ -294,7 +283,7 @@ class SMTPPool extends EventEmitter {
|
||||
* Creates a new pool resource
|
||||
*/
|
||||
_createConnection() {
|
||||
let connection = new PoolResource(this);
|
||||
const connection = new PoolResource(this);
|
||||
|
||||
connection.id = ++this._connectionCounter;
|
||||
|
||||
@@ -331,7 +320,7 @@ class SMTPPool extends EventEmitter {
|
||||
|
||||
// resource is terminated with an error
|
||||
connection.once('error', err => {
|
||||
if (err.code !== 'EMAXLIMIT') {
|
||||
if (err.code !== errors.EMAXLIMIT) {
|
||||
this.logger.warn(
|
||||
{
|
||||
err,
|
||||
@@ -450,7 +439,7 @@ class SMTPPool extends EventEmitter {
|
||||
}
|
||||
|
||||
_requeueEntryOnConnectionClose(connection) {
|
||||
connection.queueEntry.requeueAttempts = connection.queueEntry.requeueAttempts + 1;
|
||||
connection.queueEntry.requeueAttempts += 1;
|
||||
this.logger.debug(
|
||||
{
|
||||
tnx: 'pool',
|
||||
@@ -484,7 +473,7 @@ class SMTPPool extends EventEmitter {
|
||||
* @param {Object} connection The PoolResource to remove
|
||||
*/
|
||||
_removeConnection(connection) {
|
||||
let index = this._connections.indexOf(connection);
|
||||
const index = this._connections.indexOf(connection);
|
||||
|
||||
if (index !== -1) {
|
||||
this._connections.splice(index, 1);
|
||||
@@ -501,7 +490,7 @@ class SMTPPool extends EventEmitter {
|
||||
return callback();
|
||||
}
|
||||
|
||||
let now = Date.now();
|
||||
const now = Date.now();
|
||||
|
||||
if (this._rateLimit.counter < this._rateLimit.limit) {
|
||||
return callback();
|
||||
@@ -511,7 +500,9 @@ class SMTPPool extends EventEmitter {
|
||||
|
||||
if (this._rateLimit.checkpoint <= now - this._rateLimit.delta) {
|
||||
return this._clearRateLimit();
|
||||
} else if (!this._rateLimit.timeout) {
|
||||
}
|
||||
|
||||
if (!this._rateLimit.timeout) {
|
||||
this._rateLimit.timeout = setTimeout(() => this._clearRateLimit(), this._rateLimit.delta - (now - this._rateLimit.checkpoint));
|
||||
this._rateLimit.checkpoint = now;
|
||||
}
|
||||
@@ -528,7 +519,7 @@ class SMTPPool extends EventEmitter {
|
||||
|
||||
// resume all paused connections
|
||||
while (this._rateLimit.waiting.length) {
|
||||
let cb = this._rateLimit.waiting.shift();
|
||||
const cb = this._rateLimit.waiting.shift();
|
||||
setImmediate(cb);
|
||||
}
|
||||
}
|
||||
@@ -554,7 +545,7 @@ class SMTPPool extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
let auth = new PoolResource(this).auth;
|
||||
const auth = new PoolResource(this).auth;
|
||||
|
||||
this.getSocket(this.options, (err, socketOptions) => {
|
||||
if (err) {
|
||||
@@ -578,13 +569,10 @@ class SMTPPool extends EventEmitter {
|
||||
options.host || '',
|
||||
options.port || ''
|
||||
);
|
||||
options = shared.assign(false, options);
|
||||
Object.keys(socketOptions).forEach(key => {
|
||||
options[key] = socketOptions[key];
|
||||
});
|
||||
options = Object.assign(shared.assign(false, options), socketOptions);
|
||||
}
|
||||
|
||||
let connection = new SMTPConnection(options);
|
||||
const connection = new SMTPConnection(options);
|
||||
let returned = false;
|
||||
|
||||
connection.once('error', err => {
|
||||
@@ -604,7 +592,7 @@ class SMTPPool extends EventEmitter {
|
||||
return callback(new Error('Connection closed'));
|
||||
});
|
||||
|
||||
let finalize = () => {
|
||||
const finalize = () => {
|
||||
if (returned) {
|
||||
return;
|
||||
}
|
||||
@@ -633,7 +621,7 @@ class SMTPPool extends EventEmitter {
|
||||
finalize();
|
||||
});
|
||||
} else if (!auth && connection.allowsAuth && options.forceAuth) {
|
||||
let err = new Error('Authentication info was not provided');
|
||||
const err = new Error('Authentication info was not provided');
|
||||
err.code = errors.ENOAUTH;
|
||||
|
||||
returned = true;
|
||||
|
||||
Reference in New Issue
Block a user