add fs_public_ip to webhook payload (only when running in ec2 autoscale group)

This commit is contained in:
Dave Horton
2022-02-10 09:51:48 -05:00
parent d8bfa33a00
commit 941727e93f
4 changed files with 12 additions and 0 deletions

View File

@@ -71,6 +71,9 @@ class CallInfo {
} }
this.localSipAddress = srf.locals.localSipAddress; this.localSipAddress = srf.locals.localSipAddress;
if (srf.locals.publicIp) {
this.publicIp = srf.locals.publicIp;
}
} }
/** /**
@@ -121,6 +124,9 @@ class CallInfo {
if (process.env.JAMBONES_API_BASE_URL) { if (process.env.JAMBONES_API_BASE_URL) {
Object.assign(obj, {apiBaseUrl: process.env.JAMBONES_API_BASE_URL}); Object.assign(obj, {apiBaseUrl: process.env.JAMBONES_API_BASE_URL});
} }
if (this.publicIp) {
Object.assign(obj, {fsPublicIp: this.publicIp});
}
return obj; return obj;
} }

View File

@@ -45,6 +45,7 @@ class SnsNotifier extends Emitter {
}, 'response from SNS SubscribeURL'); }, 'response from SNS SubscribeURL');
const data = await this.describeInstance(); const data = await this.describeInstance();
this.lifecycleState = data.AutoScalingInstances[0].LifecycleState; this.lifecycleState = data.AutoScalingInstances[0].LifecycleState;
this.emit('SubscriptionConfirmation', {publicIp: this.publicIp});
break; break;
case 'Notification': case 'Notification':

View File

@@ -144,6 +144,7 @@ class SingleDialer extends Emitter {
* (a) create a CallInfo for this call * (a) create a CallInfo for this call
* (a) create a logger for this call * (a) create a logger for this call
*/ */
req.srf = srf;
this.callInfo = new CallInfo({ this.callInfo = new CallInfo({
direction: CallDirection.Outbound, direction: CallDirection.Outbound,
parentCallInfo: this.parentCallInfo, parentCallInfo: this.parentCallInfo,

View File

@@ -28,6 +28,10 @@ module.exports = (logger) => {
lifecycleEmitter = await require('./aws-sns-lifecycle')(logger); lifecycleEmitter = await require('./aws-sns-lifecycle')(logger);
lifecycleEmitter lifecycleEmitter
.on('SubscriptionConfirmation', ({publicIp}) => {
const {srf} = require('../..');
srf.locals.publicIp = publicIp;
})
.on(LifeCycleEvents.ScaleIn, () => { .on(LifeCycleEvents.ScaleIn, () => {
logger.info('AWS scale-in notification: begin drying up calls'); logger.info('AWS scale-in notification: begin drying up calls');
dryUpCalls = true; dryUpCalls = true;