Fixes in VERP server. The VERP server now seems to work fine.

This commit is contained in:
root 2018-12-25 21:46:52 +00:00
parent 8a38133ffc
commit a769bfb567
7 changed files with 1191 additions and 652 deletions

View file

@ -60,6 +60,7 @@ export class CKEditorHost extends Component {
onWindowResize() {
if (this.state.fullscreen) {
const newHeight = window.innerHeight - navbarHeight;
// noinspection JSIgnoredPromiseFromCall
this.contentNode.ask('setHeight', newHeight);
}
}

View file

@ -216,7 +216,7 @@ export default class CUD extends Component {
<TextArea id="description" label={t('description')}/>
<InputField id="contact_email" label={t('contactEmail')} help={t('contactEmailShownInTheListSubscription')}/>
<InputField id="contact_email" label={t('contactEmail')} help={t('contactEmailUsedInSubscriptionFormsAnd')}/>
<InputField id="homepage" label={t('homepage')} help={t('homepageUrlUsedInSubscriptionFormsAnd')}/>
<InputField id="to_name" label={t('recipientsNameTemplate')} help={t('specifyUsingMergeTagsOfThisListHowTo')}/>
<TableSelect id="send_configuration" label={t('sendConfiguration')} withHeader dropdown dataUrl='rest/send-configurations-table' columns={sendConfigurationsColumns} selectionLabelIndex={1} help={t('sendConfigurationThatWillBeUsedFor')}/>

View file

@ -182,10 +182,9 @@ class CampaignSender {
});
}
this.useVerp = config.verp.enabled && this.sendConfiguration.verp_hostname;
this.useVerpSenderHeader = this.useVerp && config.verp.disablesenderheader !== true;
});
this.useVerp = config.verp.enabled && sendConfiguration.verp_hostname;
this.useVerpSenderHeader = this.useVerp && config.verp.disablesenderheader !== true;
}
async _getMessage(campaign, list, subscriptionGrouped, mergeTags, replaceDataImgs) {

View file

@ -652,7 +652,7 @@ function getMessageCid(campaignCid, listCid, subscriptionCid) {
return [campaignCid, listCid, subscriptionCid].join('.')
}
async function getMessageByCid(messageCid) {
async function getMessageByCid(messageCid, withVerpHostname = false) { // withVerpHostname is used by verp-server.js
const messageCidElems = messageCid.split('.');
if (messageCidElems.length !== 3) {
@ -662,10 +662,10 @@ async function getMessageByCid(messageCid) {
const [campaignCid, listCid, subscriptionCid] = messageCidElems;
return await knex.transaction(async tx => {
const list = await tx('lists').where('cid', listCid).select('id');
const list = await tx('lists').where('cid', listCid).select('id').first();
const subscrTblName = subscriptions.getSubscriptionTableName(list.id);
const message = await tx('campaign_messages')
const baseQuery = tx('campaign_messages')
.innerJoin('campaigns', 'campaign_messages.campaign', 'campaigns.id')
.innerJoin(subscrTblName, subscrTblName + '.id', 'campaign_messages.subscription')
.where(subscrTblName + '.cid', subscriptionCid)
@ -675,13 +675,20 @@ async function getMessageByCid(messageCid) {
])
.first();
if (withVerpHostname) {
return await baseQuery
.innerJoin('send_configurations', 'send_configurations.id', 'campaigns.send_configuration')
.select('send_configurations.verp_hostname');
} else {
return await baseQuery;
}
return message;
});
}
async function getMessageByResponseId(responseId) {
return await knex.transaction(async tx => {
console.log(responseId);
const message = await tx('campaign_messages')
.where('campaign_messages.response_id', responseId)
.select([

1790
server/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -46,7 +46,7 @@
"bcrypt-nodejs": "0.0.3",
"bluebird": "^3.5.3",
"body-parser": "^1.18.3",
"bounce-handler": "^7.3.2-fork.2",
"bounce-handler": "github:bures/node-bounce-handler#81ccca0d9c3bbc9efea54a9eaf5f10425e2153bb",
"compression": "^1.7.3",
"config": "^2.0.1",
"connect-flash": "^0.1.1",

View file

@ -12,7 +12,7 @@ const BounceHandler = require('bounce-handler').BounceHandler;
const SMTPServer = require('smtp-server').SMTPServer;
async function onRcptTo(address, session) {
const addrSplit = address.split('@');
const addrSplit = address.address.split('@');
if (addrSplit.length !== 2) {
throw new MailerError('Unknown user ' + address.address, 510);
@ -20,7 +20,7 @@ async function onRcptTo(address, session) {
const [user, host] = addrSplit;
const message = await campaigns.getMessageByCid(user);
const message = await campaigns.getMessageByCid(user, true);
if (!message) {
throw new MailerError('Unknown user ' + address.address, 510);
@ -32,23 +32,13 @@ async function onRcptTo(address, session) {
session.message = message;
log.verbose('VERP', 'Incoming message for Campaign %s, List %s, Subscription %s', cids.campaignId, cids.listId, cids.subscriptionId);
log.verbose('VERP', 'Incoming message for Campaign %s, List %s, Subscription %s', message.campaign, message.list, message.subscription);
}
function onData(stream, session, callback) {
let chunks = [];
let totalLen = 0;
stream.on('data', chunk => {
if (!chunk || !chunk.length || totalLen > 60 * 1024) {
return;
}
chunks.push(chunk);
totalLen += chunk.length;
});
stream.on('end', () => nodeifyPromise(onStreamEnd(), callback));
const onStreamEnd = async () => {
const body = Buffer.concat(chunks, totalLen).toString();
@ -57,7 +47,7 @@ function onData(stream, session, callback) {
try {
bounceResult = [].concat(bh.parse_email(body) || []).shift();
} catch (E) {
} catch (err) {
log.error('Bounce', 'Failed parsing bounce message');
log.error('Bounce', JSON.stringify(body));
}
@ -69,6 +59,16 @@ function onData(stream, session, callback) {
log.verbose('VERP', 'Marked message %s as unsubscribed', session.message.campaign);
}
};
stream.on('data', chunk => {
if (!chunk || !chunk.length || totalLen > 60 * 1024) {
return;
}
chunks.push(chunk);
totalLen += chunk.length;
});
stream.on('end', () => nodeifyPromise(onStreamEnd(), callback));
}
// Setup server