trunk dialout add blacklist validate

This commit is contained in:
Donghuang 2021-11-07 20:47:06 +08:00
parent 6f345f45d2
commit 8a270e4a9d

View File

@ -8,6 +8,8 @@ import org.springframework.stereotype.Service;
import com.pudonghot.yo.model.domain.PhoneAlias;
import com.pudonghot.yo.mapper.PhoneAliasMapper;
import org.springframework.core.annotation.Order;
import com.pudonghot.yo.model.domain.PhoneBlacklist;
import com.pudonghot.yo.mapper.PhoneBlacklistMapper;
import com.pudonghot.yo.fsagent.service.dialplan.Call;
import org.springframework.beans.factory.annotation.Autowired;
import com.pudonghot.yo.fsagent.service.dialplan.DialplanConfig;
@ -23,6 +25,8 @@ public class DialplanService28AgentToTrunkPrefix extends BaseDialplanService {
@Autowired
private PhoneAliasMapper phoneAliasMapper;
@Autowired
private PhoneBlacklistMapper phoneBlacklistMapper;
/**
* {@inheritDoc}
@ -52,13 +56,22 @@ public class DialplanService28AgentToTrunkPrefix extends BaseDialplanService {
val calledNumberObj = getCalledNumber(tenantId, trunkInfo.getRight());
if (!calledNumberObj.isAlias()) {
if (!callerAgent.getTrunkDialAllowed()) {
log.debug("Caller [{}] is not allowed to dial trunk.", callerAgent);
log.info("Caller [{}] is not allowed to dial trunk.", callerAgent);
return null;
}
}
// number without trunk prefix
val calledNumber = calledNumberObj.getNumber();
if (phoneBlacklistMapper.exists(
new Search(PhoneBlacklist.TENANT_ID, tenantId)
.eq(PhoneBlacklist.PHONE, calledNumber)
.eq(PhoneBlacklist.ACTIVE, true))) {
log.info("Called number [{}] is in blacklist", calledNumber);
return null;
}
model.put("calledNumber", calledNumber);
model.put("targetNumber", trunkService.calledNumber(trunk, calledNumber));
recFile(model, connId, callerAgent.getAccount(), md5(calledNumber));