Socket
Socket
Sign inDemoInstall

mail-time

Package Overview
Dependencies
2
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.4 to 1.2.5

80

index.js

@@ -119,2 +119,3 @@ const JoSk = require('josk');

this.zombieTime = opts.zombieTime || 32786;
this.keepHistory = opts.keepHistory || false;

@@ -290,19 +291,9 @@ this.revolvingInterval = opts.revolvingInterval || 1536;

const cursor = this.collection.find({
$or: [{
isSent: false,
sendAt: {
$lte: new Date()
},
tries: {
$lt: this.maxTries
}
}, {
isSent: true,
sendAt: {
$lt: new Date(Date.now() - (this.zombieTime * 2))
},
tries: {
$lt: this.maxTries
}
}]
isSent: false,
sendAt: {
$lte: new Date()
},
tries: {
$lt: this.maxTries
}
}, {

@@ -332,4 +323,3 @@ projection: {

$set: {
isSent: true,
sendAt: new Date(Date.now() + (this.zombieTime * 2))
isSent: true
},

@@ -376,16 +366,11 @@ $inc: {

this.collection.deleteOne({
_id: task._id
}, defaultWriteConcern, () => {
_debug(this.debug, `email successfully sent, attempts: #${task.tries}, transport #${transportIndex} to: `, _mailOpts.to);
_debug(this.debug, `email successfully sent, attempts: #${task.tries}, transport #${transportIndex} to: `, _mailOpts.to);
if (this.keepHistory) {
this.___triggerCallbacks(void 0, task, info);
} else {
this.collection.deleteOne({ _id: task._id }, defaultWriteConcern, () => {
this.___triggerCallbacks(void 0, task, info);
});
}
const _id = task._id.toHexString();
if (this.callbacks[_id] && this.callbacks[_id].length) {
this.callbacks[_id].forEach((cb, i) => {
cb(void 0, info, task.mailOptions[i]);
});
}
delete this.callbacks[_id];
});
return;

@@ -541,12 +526,5 @@ });

_id: task._id
}, () => {
_debug(this.debug, `Giving up trying send email after ${task.tries} attempts to: `, task.mailOptions[0].to, error);
const _id = task._id.toHexString();
if (this.callbacks[_id] && this.callbacks[_id].length) {
this.callbacks[_id].forEach((cb, i) => {
cb(error, info, task.mailOptions[i]);
});
}
delete this.callbacks[_id];
}, (deleteError) => {
_debug(this.debug, `Giving up trying send email after ${task.tries} attempts to: `, task.mailOptions[0].to, error, deleteError);
this.___triggerCallbacks(error, task, info);
});

@@ -649,2 +627,20 @@ } else {

}
/*
@memberOf MailTime
@name ___triggerCallbacks
@param error {mix} - Error thrown during sending email
@param task {Object} - Task record from mongodb
@param info {Object} - Info object returned from NodeMailer's `sendMail` method
@returns {void 0}
*/
___triggerCallbacks(error, task, info) {
const _id = task._id.toHexString();
if (this.callbacks[_id] && this.callbacks[_id].length) {
this.callbacks[_id].forEach((cb, i) => {
cb(error, info, task.mailOptions[i]);
});
}
delete this.callbacks[_id];
}
};
{
"name": "mail-time",
"version": "1.2.4",
"version": "1.2.5",
"description": "Bulletproof email queue on top of NodeMailer with support of multiple clusters and servers setup",

@@ -52,13 +52,13 @@ "main": "index.js",

"deepmerge": "^4.2.2",
"josk": "^2.2.5"
"josk": "^2.3.0"
},
"devDependencies": {
"bson": "^4.0.4",
"bson-ext": "^2.0.3",
"bson": "^4.1.0",
"bson-ext": "^2.0.5",
"chai": "^4.2.0",
"mocha": "^7.1.2",
"mongodb": "^3.5.7",
"nodemailer": "^6.4.6",
"mocha": "^8.1.3",
"mongodb": "^3.6.2",
"nodemailer": "^6.4.11",
"nodemailer-direct-transport": "^3.3.2"
}
}

@@ -1,10 +0,7 @@

# MailTime
<a href="https://www.patreon.com/bePatron?u=20396046">
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
[![support](https://img.shields.io/badge/support-PayPal-white)](https://paypal.me/veliovgroup)
<a href="https://ostr.io/info/built-by-developers-for-developers">
<img src="https://ostr.io/apple-touch-icon-60x60.png" height="20">
</a>
<a href="https://ostr.io">
<img src="https://ostr.io/apple-touch-icon-60x60.png" height="38">
</a>
# MailTime

@@ -354,2 +351,3 @@ Micro-service package for mail queue, with *Server* and *Client* API.

- `opts.zombieTime` {*Number*} - [Optional] Time in *milliseconds*, after this period - pending email will be interpreted as "*zombie*". This parameter allows to rescue pending email from "*zombie* mode" in case when: server was rebooted, exception during runtime was thrown, or caused by bad logic, default - `32786`. This option is used by package itself and passed directly to [`JoSk` package](https://github.com/VeliovGroup/josk#api)
- `opts.keepHistory` {*Boolean*} - [Optional] By default sent emails not stored in the database. Set `{ keepHistory: true }` to keep queue task as it is in the database, default - `false`
- `opts.concatEmails` {*Boolean*} - [Optional] Concatenate email by `to` field, default - `false`

@@ -444,3 +442,3 @@ - `opts.concatSubject` {*String*} - [Optional] Email subject used in concatenated email, default - `Multiple notifications`

- [Become a patron](https://www.patreon.com/bePatron?u=20396046) — support my open source contributions with monthly donation
- [Support via PayPal](https://paypal.me/veliovgroup) — support my open source contributions once or on regular basis
- Use [ostr.io](https://ostr.io) — [Monitoring](https://snmp-monitoring.com), [Analytics](https://ostr.io/info/web-analytics), [WebSec](https://domain-protection.info), [Web-CRON](https://web-cron.info) and [Pre-rendering](https://prerendering.com) for a website
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc