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,38 +20,41 @@ export const hr = `<table cellspacing="0" cellpadding="0" border="0" width="100%
</tr>
</table>`;
const MailQueue = new MailTime({
db,
type: 'server',
strategy: 'balancer', // Transports will be used in round robin chain
transports,
from(transport) {
let MailQueue;
if (Meteor.settings.private.isMailServer) {
MailQueue = new MailTime({
db,
type: 'server',
strategy: 'balancer', // Transports will be used in round robin chain
transports,
from(transport) {
// To pass spam-filters `from` field should be correctly set
// for each transport, check `transport` object for more options
if (!Meteor.isProduction) {
if (!Meteor.isProduction) {
// only for test purposes
return `${i18n.t('AppName')} <notify@example.org>`;
}
return `${i18n.t('AppName')} <${transport.options.auth.user}>`;
},
debug: Meteor.settings.private.debugMailer,
concatEmails: true, // Concatenate emails to the same addressee
concatSubject: `${i18n.t('Nuevas notificaciones de {{app}}', { app: i18n.t('AppName') })}`,
/* eslint-disable */
return `${i18n.t('AppName')} <notify@example.org>`;
}
return `${i18n.t('AppName')} <${transport.options.auth.user}>`;
},
debug: Meteor.settings.private.debugMailer,
concatEmails: true, // Concatenate emails to the same addressee
concatSubject: `${i18n.t('Nuevas notificaciones de {{app}}', { app: i18n.t('AppName') })}`,
/* eslint-disable */
concatDelimiter: hr + '<h2>{{{subject}}}</h2>', // Start each concatenated email with it's own subject
/* eslint-enable */
// concatThrottling: 30,
template: MailTime.Template // Use default template
});
// A Client (not used yet)
// const MailQueueClient = new MailTime({
// db,
// type: 'client',
// debug: true,
// strategy: 'balancer', // Transports will be used in round robin chain
// concatEmails: true // Concatenate emails to the same address
// });
// concatThrottling: 30,
template: MailTime.Template // Use default template
});
} else {
MailQueue = new MailTime({
db,
type: 'client',
debug: Meteor.settings.private.debugMailer,
strategy: 'balancer', // Transports will be used in round robin chain
concatEmails: true // Concatenate emails to the same address
});
}
export default function sendMail(opts, debug) {
if (debug) {
@ -83,9 +86,12 @@ if (Meteor.settings.private.testMailer) {
// https://github.com/VeliovGroup/Mail-Time/issues/5
const MailJobs = new Mongo.Collection('__JobTasks__mailTimeQueue', { idGeneration: 'MONGO' });
const updateJob = (mailJob) => {
MailJobs.update(mailJob._id, { $set: { delay: 30000 } });
// console.log(MailJobs.findOne());
const updateJob = (mailJob, updated) => {
const delay = 60000;
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();
@ -96,9 +102,9 @@ if (mailJob) {
MailJobs.find().observe({
added: function notifAdded(item) {
updateJob(item);
updateJob(item, false);
},
changed: function notifChanged(item) {
updateJob(item);
updateJob(item, true);
}
});

View file

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