mirror of
https://github.com/eleith/emailjs.git
synced 2024-07-05 20:10:37 +00:00
nits
This commit is contained in:
parent
ba41892117
commit
83587cb1b7
116
smtp/client.js
116
smtp/client.js
@ -55,6 +55,64 @@ class Client {
|
||||
this.ready = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Message|MessageStack} msg msg
|
||||
* @param {function(Error, MessageStack): void} callback callback
|
||||
* @returns {void}
|
||||
*/
|
||||
send(msg, callback) {
|
||||
/**
|
||||
* @type {Message}
|
||||
*/
|
||||
const message =
|
||||
msg instanceof Message
|
||||
? msg
|
||||
: this._canMakeMessage(msg)
|
||||
? create(msg)
|
||||
: null;
|
||||
|
||||
if (message == null) {
|
||||
callback(
|
||||
new Error('message is not a valid Message instance'),
|
||||
/** @type {MessageStack} */ (msg)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
message.valid((valid, why) => {
|
||||
if (valid) {
|
||||
const stack = {
|
||||
message,
|
||||
to: addressparser(message.header.to),
|
||||
from: addressparser(message.header.from)[0].address,
|
||||
callback: (callback || function() {}).bind(this),
|
||||
};
|
||||
|
||||
if (message.header.cc) {
|
||||
stack.to = stack.to.concat(addressparser(message.header.cc));
|
||||
}
|
||||
|
||||
if (message.header.bcc) {
|
||||
stack.to = stack.to.concat(addressparser(message.header.bcc));
|
||||
}
|
||||
|
||||
if (
|
||||
message.header['return-path'] &&
|
||||
addressparser(message.header['return-path']).length
|
||||
) {
|
||||
stack.returnPath = addressparser(
|
||||
message.header['return-path']
|
||||
)[0].address;
|
||||
}
|
||||
|
||||
this.queue.push(stack);
|
||||
this._poll();
|
||||
} else {
|
||||
callback(new Error(why), /** @type {MessageStack} */ (msg));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @returns {void}
|
||||
@ -123,64 +181,6 @@ class Client {
|
||||
this.smtp.connect(connect);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Message|MessageStack} msg msg
|
||||
* @param {function(Error, MessageStack): void} callback callback
|
||||
* @returns {void}
|
||||
*/
|
||||
send(msg, callback) {
|
||||
/**
|
||||
* @type {Message}
|
||||
*/
|
||||
const message =
|
||||
msg instanceof Message
|
||||
? msg
|
||||
: this._canMakeMessage(msg)
|
||||
? create(msg)
|
||||
: null;
|
||||
|
||||
if (message == null) {
|
||||
callback(
|
||||
new Error('message is not a valid Message instance'),
|
||||
/**@type {MessageStack}*/ (msg)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
message.valid((valid, why) => {
|
||||
if (valid) {
|
||||
const stack = {
|
||||
message,
|
||||
to: addressparser(message.header.to),
|
||||
from: addressparser(message.header.from)[0].address,
|
||||
callback: (callback || function() {}).bind(this),
|
||||
};
|
||||
|
||||
if (message.header.cc) {
|
||||
stack.to = stack.to.concat(addressparser(message.header.cc));
|
||||
}
|
||||
|
||||
if (message.header.bcc) {
|
||||
stack.to = stack.to.concat(addressparser(message.header.bcc));
|
||||
}
|
||||
|
||||
if (
|
||||
message.header['return-path'] &&
|
||||
addressparser(message.header['return-path']).length
|
||||
) {
|
||||
stack.returnPath = addressparser(
|
||||
message.header['return-path']
|
||||
)[0].address;
|
||||
}
|
||||
|
||||
this.queue.push(stack);
|
||||
this._poll();
|
||||
} else {
|
||||
callback(new Error(why), /**@type {MessageStack}*/ (msg));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {MessageStack} msg message stack
|
||||
|
@ -684,7 +684,7 @@ class SMTP extends EventEmitter {
|
||||
);
|
||||
|
||||
/**
|
||||
* see: https://developers.google.com/gmail/xoauth2_protocol
|
||||
* @see https://developers.google.com/gmail/xoauth2_protocol
|
||||
* @returns {string} base64 xoauth2 auth token
|
||||
*/
|
||||
const encode_xoauth2 = () =>
|
||||
|
Loading…
Reference in New Issue
Block a user