mirror of
https://github.com/eleith/emailjs.git
synced 2024-07-05 20:10:37 +00:00
extract canMakeMessage to private method
This commit is contained in:
parent
845e2bd489
commit
2e6d32a403
@ -127,23 +127,15 @@ class Client {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
send(msg, callback) {
|
send(msg, callback) {
|
||||||
/**
|
|
||||||
* @param {MessageStack} m message stack
|
|
||||||
* @returns {boolean} can make message
|
|
||||||
*/
|
|
||||||
const canMakeMessage = m => {
|
|
||||||
return (
|
|
||||||
m.from &&
|
|
||||||
(m.to || m.cc || m.bcc) &&
|
|
||||||
(m.text !== undefined || this._containsInlinedHtml(m.attachment))
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Message}
|
* @type {Message}
|
||||||
*/
|
*/
|
||||||
const message =
|
const message =
|
||||||
msg instanceof Message ? msg : canMakeMessage(msg) ? create(msg) : null;
|
msg instanceof Message
|
||||||
|
? msg
|
||||||
|
: this._canMakeMessage(msg)
|
||||||
|
? create(msg)
|
||||||
|
: null;
|
||||||
|
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
callback(
|
callback(
|
||||||
@ -187,6 +179,18 @@ class Client {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {MessageStack} msg message stack
|
||||||
|
* @returns {boolean} can make message
|
||||||
|
*/
|
||||||
|
_canMakeMessage(msg) {
|
||||||
|
return (
|
||||||
|
msg.from &&
|
||||||
|
(msg.to || msg.cc || msg.bcc) &&
|
||||||
|
(msg.text !== undefined || this._containsInlinedHtml(msg.attachment))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {*} attachment attachment
|
* @param {*} attachment attachment
|
||||||
* @returns {boolean} does contain
|
* @returns {boolean} does contain
|
||||||
|
Loading…
Reference in New Issue
Block a user