diff --git a/config/index.js b/config/index.js index 21dc1f207..f770fd052 100644 --- a/config/index.js +++ b/config/index.js @@ -606,6 +606,16 @@ var conf = convict({ format: RegExp, env: 'SMS_REGIONS' }, + senderIds: { + doc: 'Sender ids keyed by the region they apply to', + default: { + CA: '16474909977', + GB: 'Firefox', + US: '15036789977' + }, + format: Object, + env: 'SMS_SENDER_IDS' + }, installFirefoxLink: { doc: 'Link for the installFirefox SMS template', default: 'https://mzl.la/1HOd4ec', diff --git a/config/sms-sender-ids.json b/config/sms-sender-ids.json deleted file mode 100644 index 72932a169..000000000 --- a/config/sms-sender-ids.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - [ "CA", "16474909977" ], - [ "GB", "Firefox" ], - [ "US", "15036789977" ] -] diff --git a/lib/routes/sms.js b/lib/routes/sms.js index 60bdeaadc..d802aaa40 100644 --- a/lib/routes/sms.js +++ b/lib/routes/sms.js @@ -9,7 +9,6 @@ const PhoneNumberUtil = require('google-libphonenumber').PhoneNumberUtil const validators = require('./validators') const METRICS_CONTEXT_SCHEMA = require('../metrics/context').schema -const SENDER_IDS = new Map(require('../../config/sms-sender-ids.json')) module.exports = (log, isA, error, config, customs, sms) => { if (! config.sms.enabled) { @@ -18,6 +17,7 @@ module.exports = (log, isA, error, config, customs, sms) => { const getGeoData = require('../geodb')(log) const REGIONS = config.sms.regions + const SENDER_IDS = config.sms.senderIds return [ { @@ -68,7 +68,7 @@ module.exports = (log, isA, error, config, customs, sms) => { function getRegionSpecificSenderId () { const region = phoneNumberUtil.getRegionCodeForNumber(parsedPhoneNumber) - const senderId = SENDER_IDS.get(region) + const senderId = SENDER_IDS[region] if (! senderId) { throw error.invalidRegion(region) diff --git a/test/local/routes/sms.js b/test/local/routes/sms.js index 3e62887b7..9501e3d97 100644 --- a/test/local/routes/sms.js +++ b/test/local/routes/sms.js @@ -42,7 +42,12 @@ describe('/sms', () => { log = mocks.spyLog() config = { sms: { - enabled: true + enabled: true, + senderIds: { + CA: '16474909977', + GB: 'Firefox', + US: '15036789977' + } } } routes = makeRoutes({ log, config })