Skip to content

Commit 378fcca

Browse files
MSB-196: Add extensions preOutbound to UssdCallManager
1 parent 15fc490 commit 378fcca

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

restcomm/restcomm.ussd/src/main/java/org/restcomm/connect/ussd/telephony/UssdCallManager.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
import org.restcomm.connect.dao.entities.Application;
5252
import org.restcomm.connect.dao.entities.IncomingPhoneNumber;
5353
import org.restcomm.connect.dao.entities.MostOptimalNumberResponse;
54+
import org.restcomm.connect.extension.api.ExtensionType;
55+
import org.restcomm.connect.extension.api.RestcommExtensionException;
56+
import org.restcomm.connect.extension.api.RestcommExtensionGeneric;
57+
import org.restcomm.connect.extension.controller.ExtensionController;
5458
import org.restcomm.connect.http.client.rcmlserver.resolver.RcmlserverResolver;
5559
import org.restcomm.connect.interpreter.StartInterpreter;
5660
import org.restcomm.connect.telephony.api.CallManagerResponse;
@@ -86,6 +90,9 @@ public class UssdCallManager extends RestcommUntypedActor {
8690
private final String ussdGatewayUsername;
8791
private final String ussdGatewayPassword;
8892

93+
//List of extensions for CallManager
94+
List<RestcommExtensionGeneric> extensions;
95+
8996
// configurable switch whether to use the To field in a SIP header to determine the callee address
9097
// alternatively the Request URI can be used
9198
private boolean useTo;
@@ -111,6 +118,10 @@ public UssdCallManager(Configuration configuration, ServletContext context, SipF
111118
this.ussdGatewayUri = ussdGatewayConfig.getString("ussd-gateway-uri");
112119
this.ussdGatewayUsername = ussdGatewayConfig.getString("ussd-gateway-user");
113120
this.ussdGatewayPassword = ussdGatewayConfig.getString("ussd-gateway-password");
121+
extensions = ExtensionController.getInstance().getExtensions(ExtensionType.CallManager);
122+
if (logger.isInfoEnabled()) {
123+
logger.info("UssdCallManager extensions: " + (extensions != null ? extensions.size() : "0"));
124+
}
114125
}
115126

116127
private ActorRef ussdCall() {
@@ -161,8 +172,18 @@ public void onReceive(final Object message) throws Exception {
161172
response(message);
162173
} else if (CreateCall.class.equals(klass)) {
163174
try {
175+
ExtensionController ec = ExtensionController.getInstance();
164176
this.createCallRequest = (CreateCall) message;
165-
sender.tell(new CallManagerResponse<ActorRef>(outbound(message)), self);
177+
ec.executePreOutboundAction(this.createCallRequest, extensions);
178+
if(this.createCallRequest.isAllowed()){
179+
sender.tell(new CallManagerResponse<ActorRef>(outbound(message)), self);
180+
}else{
181+
//Extensions didn't allowed this call
182+
final String errMsg = "Not Allowed to make this outbound call";
183+
logger.warning(errMsg);
184+
sender.tell(new CallManagerResponse<ActorRef>(new RestcommExtensionException(errMsg), this.createCallRequest), self());
185+
}
186+
166187
} catch (final Exception exception) {
167188
sender.tell(new CallManagerResponse<ActorRef>(exception), self);
168189
}

0 commit comments

Comments
 (0)