diff --git a/lib/functions/processMessage.js b/lib/functions/processMessage.js index a0a0fba..3141227 100644 --- a/lib/functions/processMessage.js +++ b/lib/functions/processMessage.js @@ -41,12 +41,12 @@ module.exports.processMessage = async (event) => { // If the last message is active then update references and msgtype if (lastMessage && lastMessage.expires > new Date()) { - xmlResult.alert.references = [lastMessage.references ? lastMessage.references + ' ' + xmlResult.alert.sender[0] + ',' + xmlResult.alert.identifier + ',' + moment(xmlResult.alert.sent).utc().format('YYYY-MM-DDTHH:mm:ssZ') : xmlResult.alert.sender[0] + ',' + lastMessage.identifier + ',' + moment(lastMessage.sent).utc().format('YYYY-MM-DDTHH:mm:ssZ')] + xmlResult.alert.references = [lastMessage.references ? lastMessage.references + ' ' + xmlResult.alert.sender[0] + ',' + lastMessage.identifier + ',' + moment(lastMessage.sent).utc().format('YYYY-MM-DDTHH:mm:ssZ') : xmlResult.alert.sender[0] + ',' + lastMessage.identifier + ',' + moment(lastMessage.sent).utc().format('YYYY-MM-DDTHH:mm:ssZ')] xmlResult.alert.msgType[0] = xmlResult.alert.msgType[0] === 'Alert' ? 'Update' : xmlResult.alert.msgType[0] } else { delete xmlResult.alert.references } - + const message = new Message(xmlResult) console.log('Processing CAP message: ' + message.data.identifier + ' for ' + message.data.fwis_code) diff --git a/test/processMessage.js b/test/processMessage.js index a635916..40da9b0 100644 --- a/test/processMessage.js +++ b/test/processMessage.js @@ -5,6 +5,7 @@ const lab = exports.lab = Lab.script() const Code = require('code') const processMessage = require('../lib/functions/processMessage').processMessage const service = require('../lib/helpers/service') +const moment = require('moment') let capAlert let capUpdate @@ -314,9 +315,11 @@ lab.experiment('processMessage', () => { service.putMessage = (query) => { return new Promise((resolve, reject) => { + const lastDate = moment(yesterday).utc().format('YYYY-MM-DDTHH:mm:ssZ') Code.expect(query.values[2]).to.not.be.empty() Code.expect(query.values[1]).to.equal('Update') - Code.expect(query.values[2]).to.contain('Previous_Active_Message www.gov.uk/environment-agency') + Code.expect(query.values[2]).to.contain(`Previous_Active_Message www.gov.uk/environment-agency,4eb3b7350ab7aa443650fc9351f2,${lastDate}`) + Code.expect(query.values[2]).to.not.contain('00:00+00:00') resolve() }) }