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;
|
||||
|
||||
20
node_modules/nodemailer/lib/smtp-pool/pool-resource.js
generated
vendored
20
node_modules/nodemailer/lib/smtp-pool/pool-resource.js
generated
vendored
@@ -23,7 +23,7 @@ class PoolResource extends EventEmitter {
|
||||
if (this.options.auth) {
|
||||
switch ((this.options.auth.type || '').toString().toUpperCase()) {
|
||||
case 'OAUTH2': {
|
||||
let oauth2 = new XOAuth2(this.options.auth, this.logger);
|
||||
const oauth2 = new XOAuth2(this.options.auth, this.logger);
|
||||
oauth2.provisionCallback =
|
||||
(this.pool.mailer && this.pool.mailer.get('oauth2_provision_cb')) || oauth2.provisionCallback;
|
||||
this.auth = {
|
||||
@@ -90,10 +90,7 @@ class PoolResource extends EventEmitter {
|
||||
options.port || ''
|
||||
);
|
||||
|
||||
options = assign(false, options);
|
||||
Object.keys(socketOptions).forEach(key => {
|
||||
options[key] = socketOptions[key];
|
||||
});
|
||||
options = Object.assign(assign(false, options), socketOptions);
|
||||
}
|
||||
|
||||
this.connection = new SMTPConnection(options);
|
||||
@@ -114,12 +111,12 @@ class PoolResource extends EventEmitter {
|
||||
}
|
||||
returned = true;
|
||||
|
||||
let timer = setTimeout(() => {
|
||||
const timer = setTimeout(() => {
|
||||
if (returned) {
|
||||
return;
|
||||
}
|
||||
// still have not returned, this means we have an unexpected connection close
|
||||
let err = new Error('Unexpected socket close');
|
||||
const err = new Error('Unexpected socket close');
|
||||
if (this.connection && this.connection._socket && this.connection._socket.upgrading) {
|
||||
// starttls connection errors
|
||||
err.code = errors.ETLS;
|
||||
@@ -180,10 +177,10 @@ class PoolResource extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
let envelope = mail.message.getEnvelope();
|
||||
let messageId = mail.message.messageId();
|
||||
const envelope = mail.message.getEnvelope();
|
||||
const messageId = mail.message.messageId();
|
||||
|
||||
let recipients = [].concat(envelope.to || []);
|
||||
const recipients = [].concat(envelope.to || []);
|
||||
if (recipients.length > 3) {
|
||||
recipients.push('...and ' + recipients.splice(2).length + ' more');
|
||||
}
|
||||
@@ -224,9 +221,8 @@ class PoolResource extends EventEmitter {
|
||||
info.messageId = messageId;
|
||||
|
||||
setImmediate(() => {
|
||||
let err;
|
||||
if (this.messages >= this.options.maxMessages) {
|
||||
err = new Error('Resource exhausted');
|
||||
const err = new Error('Resource exhausted');
|
||||
err.code = errors.EMAXLIMIT;
|
||||
this.connection.close();
|
||||
this.emit('error', err);
|
||||
|
||||
Reference in New Issue
Block a user