-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reject old-format Benin numbers, which are now undeliverable
- Loading branch information
1 parent
f4a2438
commit 3a4a55c
Showing
7 changed files
with
83 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...va/org/whispersystems/textsecuregcm/mappers/ObsoletePhoneNumberFormatExceptionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.whispersystems.textsecuregcm.mappers; | ||
|
||
import io.micrometer.core.instrument.Metrics; | ||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.ext.ExceptionMapper; | ||
import org.whispersystems.textsecuregcm.metrics.MetricsUtil; | ||
import org.whispersystems.textsecuregcm.util.ObsoletePhoneNumberFormatException; | ||
|
||
public class ObsoletePhoneNumberFormatExceptionMapper implements ExceptionMapper<ObsoletePhoneNumberFormatException> { | ||
|
||
private static final String COUNTER_NAME = MetricsUtil.name(ObsoletePhoneNumberFormatExceptionMapper.class, "errors"); | ||
|
||
@Override | ||
public Response toResponse(final ObsoletePhoneNumberFormatException exception) { | ||
Metrics.counter(COUNTER_NAME, "regionCode", exception.getRegionCode()).increment(); | ||
return Response.status(499).build(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...c/main/java/org/whispersystems/textsecuregcm/util/ObsoletePhoneNumberFormatException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.whispersystems.textsecuregcm.util; | ||
|
||
public class ObsoletePhoneNumberFormatException extends Exception { | ||
|
||
private final String regionCode; | ||
|
||
public ObsoletePhoneNumberFormatException(final String regionCode) { | ||
super("The provided format is obsolete in %s".formatted(regionCode)); | ||
this.regionCode = regionCode; | ||
} | ||
|
||
public String getRegionCode() { | ||
return regionCode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters