mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 17:18:06 +01:00
Verify that nobody's addressing API calls by e164 any more.
This commit is contained in:
committed by
Jon Chambers
parent
5400abb065
commit
44838d6238
@@ -5,13 +5,22 @@
|
||||
|
||||
package org.whispersystems.textsecuregcm.auth;
|
||||
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
import io.micrometer.core.instrument.Tags;
|
||||
import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.codahale.metrics.MetricRegistry.name;
|
||||
|
||||
public class AmbiguousIdentifier {
|
||||
|
||||
private final UUID uuid;
|
||||
private final String number;
|
||||
|
||||
private static final String REQUEST_COUNTER_NAME = name(AmbiguousIdentifier.class, "request");
|
||||
|
||||
public AmbiguousIdentifier(String target) {
|
||||
if (target.startsWith("+")) {
|
||||
this.uuid = null;
|
||||
@@ -42,4 +51,11 @@ public class AmbiguousIdentifier {
|
||||
public String toString() {
|
||||
return hasUuid() ? uuid.toString() : number;
|
||||
}
|
||||
|
||||
public void incrementRequestCounter(final String context, @Nullable final String userAgent) {
|
||||
Metrics.counter(REQUEST_COUNTER_NAME, Tags.of(
|
||||
Tag.of("type", hasUuid() ? "uuid" : "e164"),
|
||||
Tag.of("context", context),
|
||||
UserAgentTagUtil.getPlatformTag(userAgent))).increment();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user