Compare commits

..
6 Commits
Author SHA1 Message Date
Moxie Marlinspike aa2a5ff929 Bump version to 0.26
// FREEBIE
2014-12-03 13:36:25 -08:00
Moxie Marlinspike 56d3c1e73f Turn down log levels.
// FREEBIE
2014-12-03 11:44:40 -08:00
Moxie Marlinspike f401f9a674 Schedule at 1min instead of 10min.
// FREEBIE
2014-12-03 11:35:38 -08:00
Moxie Marlinspike 30933d792b Timestamp comparison should be the other way.
// FREEBIE
2014-12-03 11:33:34 -08:00
Moxie Marlinspike 905717977e Turn down logging on metrics reporter.
// FREEBIE
2014-12-03 11:09:37 -08:00
Moxie Marlinspike b802994809 Do a timestamp comparison on unregister events.
// FREEBIE
2014-12-03 11:09:01 -08:00
5 changed files with 44 additions and 14 deletions

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@
<groupId>org.whispersystems.textsecure</groupId>
<artifactId>TextSecureServer</artifactId>
<version>0.25</version>
<version>0.26</version>
<properties>
<dropwizard.version>0.7.1</dropwizard.version>
@@ -19,6 +19,9 @@ public class UnregisteredEvent {
@Min(1)
private int deviceId;
@JsonProperty
private long timestamp;
public String getRegistrationId() {
return registrationId;
}
@@ -30,4 +33,8 @@ public class UnregisteredEvent {
public int getDeviceId() {
return deviceId;
}
public long getTimestamp() {
return timestamp;
}
}
@@ -56,7 +56,7 @@ public class JsonMetricsReporter extends ScheduledReporter {
SortedMap<String, Timer> stringTimerSortedMap)
{
try {
logger.info("Reporting metrics...");
logger.debug("Reporting metrics...");
URL url = new URL("https", sunnylabsHost, 443, "/report/metrics?t=" + table + "&h=" + host);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
@@ -93,7 +93,7 @@ public class JsonMetricsReporter extends ScheduledReporter {
outputStream.close();
logger.info("Metrics server response: " + connection.getResponseCode());
logger.debug("Metrics server response: " + connection.getResponseCode());
} catch (IOException e) {
logger.warn("Error sending metrics", e);
} catch (Exception e) {
@@ -33,7 +33,7 @@ public class FeedbackHandler implements Managed, Runnable {
@Override
public void start() throws Exception {
this.executor = Executors.newSingleThreadScheduledExecutor();
this.executor.scheduleAtFixedRate(this, 0, 10, TimeUnit.MINUTES);
this.executor.scheduleAtFixedRate(this, 0, 1, TimeUnit.MINUTES);
}
@Override
@@ -62,7 +62,7 @@ public class FeedbackHandler implements Managed, Runnable {
}
private void handleGcmUnregistered(UnregisteredEvent event) {
logger.warn("Got GCM Unregistered: " + event.getNumber() + "," + event.getDeviceId());
logger.info("Got GCM Unregistered: " + event.getNumber() + "," + event.getDeviceId());
Optional<Account> account = accountsManager.get(event.getNumber());
@@ -71,16 +71,21 @@ public class FeedbackHandler implements Managed, Runnable {
if (device.isPresent()) {
if (event.getRegistrationId().equals(device.get().getGcmId())) {
logger.warn("GCM Unregister GCM ID matches!");
device.get().setGcmId(null);
accountsManager.update(account.get());
logger.info("GCM Unregister GCM ID matches!");
if (device.get().getPushTimestamp() == 0 ||
event.getTimestamp() > device.get().getPushTimestamp())
{
logger.info("GCM Unregister Timestamp matches!");
device.get().setGcmId(null);
accountsManager.update(account.get());
}
}
}
}
}
private void handleApnUnregistered(UnregisteredEvent event) {
logger.warn("Got APN Unregistered: " + event.getNumber() + "," + event.getDeviceId());
logger.info("Got APN Unregistered: " + event.getNumber() + "," + event.getDeviceId());
Optional<Account> account = accountsManager.get(event.getNumber());
@@ -89,9 +94,14 @@ public class FeedbackHandler implements Managed, Runnable {
if (device.isPresent()) {
if (event.getRegistrationId().equals(device.get().getApnId())) {
logger.warn("APN Unregister APN ID matches!");
device.get().setApnId(null);
accountsManager.update(account.get());
logger.info("APN Unregister APN ID matches!");
if (device.get().getPushTimestamp() == 0 ||
event.getTimestamp() > device.get().getPushTimestamp())
{
logger.info("APN Unregister timestamp matches!");
device.get().setApnId(null);
accountsManager.update(account.get());
}
}
}
}
@@ -22,8 +22,6 @@ import org.whispersystems.textsecuregcm.auth.AuthenticationCredentials;
import org.whispersystems.textsecuregcm.entities.SignedPreKey;
import org.whispersystems.textsecuregcm.util.Util;
import java.io.Serializable;
public class Device {
public static final long MASTER_ID = 1;
@@ -46,6 +44,9 @@ public class Device {
@JsonProperty
private String apnId;
@JsonProperty
private long pushTimestamp;
@JsonProperty
private boolean fetchesMessages;
@@ -79,6 +80,10 @@ public class Device {
public void setApnId(String apnId) {
this.apnId = apnId;
if (apnId != null) {
this.pushTimestamp = System.currentTimeMillis();
}
}
public String getGcmId() {
@@ -87,6 +92,10 @@ public class Device {
public void setGcmId(String gcmId) {
this.gcmId = gcmId;
if (gcmId != null) {
this.pushTimestamp = System.currentTimeMillis();
}
}
public long getId() {
@@ -145,4 +154,8 @@ public class Device {
public void setSignedPreKey(SignedPreKey signedPreKey) {
this.signedPreKey = signedPreKey;
}
public long getPushTimestamp() {
return pushTimestamp;
}
}