Added isMailServer setting for Mail-Time server/client configuration

This commit is contained in:
vjrj 2018-04-04 08:31:02 +02:00
parent 0026b498eb
commit ea50b17df3
2 changed files with 40 additions and 32 deletions

View file

@ -20,7 +20,10 @@ export const hr = `<table cellspacing="0" cellpadding="0" border="0" width="100%
</tr> </tr>
</table>`; </table>`;
const MailQueue = new MailTime({ let MailQueue;
if (Meteor.settings.private.isMailServer) {
MailQueue = new MailTime({
db, db,
type: 'server', type: 'server',
strategy: 'balancer', // Transports will be used in round robin chain strategy: 'balancer', // Transports will be used in round robin chain
@ -43,15 +46,15 @@ const MailQueue = new MailTime({
// concatThrottling: 30, // concatThrottling: 30,
template: MailTime.Template // Use default template template: MailTime.Template // Use default template
}); });
} else {
// A Client (not used yet) MailQueue = new MailTime({
// const MailQueueClient = new MailTime({ db,
// db, type: 'client',
// type: 'client', debug: Meteor.settings.private.debugMailer,
// debug: true, strategy: 'balancer', // Transports will be used in round robin chain
// strategy: 'balancer', // Transports will be used in round robin chain concatEmails: true // Concatenate emails to the same address
// concatEmails: true // Concatenate emails to the same address });
// }); }
export default function sendMail(opts, debug) { export default function sendMail(opts, debug) {
if (debug) { if (debug) {
@ -83,9 +86,12 @@ if (Meteor.settings.private.testMailer) {
// https://github.com/VeliovGroup/Mail-Time/issues/5 // https://github.com/VeliovGroup/Mail-Time/issues/5
const MailJobs = new Mongo.Collection('__JobTasks__mailTimeQueue', { idGeneration: 'MONGO' }); const MailJobs = new Mongo.Collection('__JobTasks__mailTimeQueue', { idGeneration: 'MONGO' });
const updateJob = (mailJob) => { const updateJob = (mailJob, updated) => {
MailJobs.update(mailJob._id, { $set: { delay: 30000 } }); const delay = 60000;
// console.log(MailJobs.findOne()); if (Meteor.isDevelopment) console.log(`${updated ? 'Update old' : 'Update just added'} mailjob with ${delay} delay`);
if (mailJob.delay !== delay) {
MailJobs.update(mailJob._id, { $set: { delay } });
}
}; };
const mailJob = MailJobs.findOne(); const mailJob = MailJobs.findOne();
@ -96,9 +102,9 @@ if (mailJob) {
MailJobs.find().observe({ MailJobs.find().observe({
added: function notifAdded(item) { added: function notifAdded(item) {
updateJob(item); updateJob(item, false);
}, },
changed: function notifChanged(item) { changed: function notifChanged(item) {
updateJob(item); updateJob(item, true);
} }
}); });

View file

@ -21,6 +21,8 @@
"testMailer": false, "testMailer": false,
"debugMailer": false, "debugMailer": false,
"MAIL_URL": "", "MAIL_URL": "",
"// isMailServer": "See: https://github.com/VeliovGroup/Mail-Time",
"isMailServer": true,
"fireIconUrl": "https://testfuegos.comunes.org/fire-marker.png", "fireIconUrl": "https://testfuegos.comunes.org/fire-marker.png",
"OAuth": { "OAuth": {
"google": { "google": {