mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-19 03:28:05 +01:00
Extract "is ported" data from HLR Lookup responses
This commit is contained in:
committed by
ravi-signal
parent
ff8194ae5f
commit
c0d0d5f5da
@@ -147,7 +147,8 @@ public class HlrLookupCarrierDataProvider implements CarrierDataProvider {
|
||||
networkDetails.name(),
|
||||
lineType(result.telephoneNumberType()),
|
||||
mccFromMccMnc(networkDetails.mccmnc()),
|
||||
mncFromMccMnc(networkDetails.mccmnc()), Optional.empty()));
|
||||
mncFromMccMnc(networkDetails.mccmnc()),
|
||||
isPorted(result.isPorted())));
|
||||
}
|
||||
|
||||
private static Tag getCreditsSpentTag(final HlrLookupResult hlrLookupResult) {
|
||||
@@ -174,15 +175,12 @@ public class HlrLookupCarrierDataProvider implements CarrierDataProvider {
|
||||
|
||||
@VisibleForTesting
|
||||
static CarrierData.LineType lineType(@Nullable final String telephoneNumberType) {
|
||||
if (telephoneNumberType == null) {
|
||||
return CarrierData.LineType.UNKNOWN;
|
||||
}
|
||||
|
||||
return switch (telephoneNumberType) {
|
||||
case "MOBILE" -> CarrierData.LineType.MOBILE;
|
||||
case "LANDLINE", "MOBILE_OR_LANDLINE" -> CarrierData.LineType.LANDLINE;
|
||||
case "VOIP" -> CarrierData.LineType.NON_FIXED_VOIP;
|
||||
case "UNKNOWN" -> CarrierData.LineType.UNKNOWN;
|
||||
case null -> CarrierData.LineType.UNKNOWN;
|
||||
default -> CarrierData.LineType.OTHER;
|
||||
};
|
||||
}
|
||||
@@ -198,6 +196,15 @@ public class HlrLookupCarrierDataProvider implements CarrierDataProvider {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static Optional<Boolean> isPorted(@Nullable final String isPorted) {
|
||||
return switch (isPorted) {
|
||||
case "YES" -> Optional.of(true);
|
||||
case "NO" -> Optional.of(false);
|
||||
case null, default -> Optional.empty();
|
||||
};
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static HlrLookupResponse parseResponse(final String responseJson) throws JsonProcessingException {
|
||||
return OBJECT_MAPPER.readValue(responseJson, HlrLookupResponse.class);
|
||||
|
||||
@@ -15,5 +15,6 @@ record HlrLookupResult(String error,
|
||||
NetworkDetails originalNetworkDetails,
|
||||
String currentNetwork,
|
||||
NetworkDetails currentNetworkDetails,
|
||||
String telephoneNumberType) {
|
||||
String telephoneNumberType,
|
||||
String isPorted) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user