This commit is contained in:
Andris Reinman 2017-07-31 00:42:06 +03:00
parent 7ed4362ff9
commit b0a060bc75
2 changed files with 1 additions and 11 deletions

View file

@ -5,7 +5,6 @@ const MessageSplitter = require('./message-splitter');
const db = require('./db');
const consts = require('./consts');
const maildrop = require('./maildrop');
const log = require('npmlog');
module.exports = (options, callback) => {
if (!options.sender || /mailer-daemon|no-?reply/gi.test(options.sender)) {
@ -16,7 +15,7 @@ module.exports = (options, callback) => {
if (err) {
return callback(err);
}
log.info('ggg', JSON.stringify(autoreply));
if (!autoreply || !autoreply.status) {
return callback(null, false);
}
@ -34,23 +33,19 @@ module.exports = (options, callback) => {
let autoSubmitted = headers.getFirst('Auto-Submitted');
if (autoSubmitted && autoSubmitted.toLowerCase() !== 'no') {
log.info('ggg', 1, autoSubmitted);
// skip automatic messages
return callback(null, false);
}
let precedence = headers.getFirst('Precedence');
if (precedence && ['list', 'junk', 'bulk'].includes(precedence.toLowerCase())) {
log.info('ggg', 2, precedence);
return callback(null, false);
}
let listUnsubscribe = headers.getFirst('List-Unsubscribe');
if (listUnsubscribe) {
log.info('ggg', 3, listUnsubscribe);
return callback(null, false);
}
let suppressAutoresponse = headers.getFirst('X-Auto-Response-Suppress');
if (suppressAutoresponse && /OOF|AutoReply/i.test(suppressAutoresponse)) {
log.info('ggg', 4, suppressAutoresponse);
return callback(null, false);
}
@ -62,20 +57,17 @@ module.exports = (options, callback) => {
.zadd('war:' + options.user._id, 'NX', Date.now(), options.sender)
.exec((err, response) => {
if (err) {
log.info('ggg', 5, err.message);
return callback(null, false);
}
if (!response || !response[1]) {
// already responded
log.info('ggg', 6, response);
return callback(null, false);
}
// check limiting counters
options.messageHandler.counters.ttlcounter('wda:' + options.user._id, 1, consts.MAX_AUTOREPLIES, (err, result) => {
if (err || !result.success) {
log.info('ggg', 7, (err && err.message) || result);
return callback(null, false);
}
@ -103,7 +95,6 @@ module.exports = (options, callback) => {
text: autoreply.message
};
log.info('ggg', 8, JSON.stringify(data));
let compiler = new MailComposer(data);
let message = maildrop(
{

View file

@ -267,7 +267,6 @@ const serverOptions = {
};
let sendAutoreply = done => {
log.info('dddd', JSON.stringify({ sender, user }));
// never reply to messages marked as spam
if (!sender || !user.autoreply || filterActions.get('spam')) {
return setImmediate(done);