Do a timestamp comparison on unregister events.
// FREEBIE
This commit is contained in:
parent
ac96f906b3
commit
b802994809
|
@ -19,6 +19,9 @@ public class UnregisteredEvent {
|
||||||
@Min(1)
|
@Min(1)
|
||||||
private int deviceId;
|
private int deviceId;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private long timestamp;
|
||||||
|
|
||||||
public String getRegistrationId() {
|
public String getRegistrationId() {
|
||||||
return registrationId;
|
return registrationId;
|
||||||
}
|
}
|
||||||
|
@ -30,4 +33,8 @@ public class UnregisteredEvent {
|
||||||
public int getDeviceId() {
|
public int getDeviceId() {
|
||||||
return deviceId;
|
return deviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,13 @@ public class FeedbackHandler implements Managed, Runnable {
|
||||||
if (device.isPresent()) {
|
if (device.isPresent()) {
|
||||||
if (event.getRegistrationId().equals(device.get().getGcmId())) {
|
if (event.getRegistrationId().equals(device.get().getGcmId())) {
|
||||||
logger.warn("GCM Unregister GCM ID matches!");
|
logger.warn("GCM Unregister GCM ID matches!");
|
||||||
device.get().setGcmId(null);
|
if (device.get().getPushTimestamp() == 0 ||
|
||||||
accountsManager.update(account.get());
|
event.getTimestamp() < device.get().getPushTimestamp())
|
||||||
|
{
|
||||||
|
logger.warn("GCM Unregister Timestamp matches!");
|
||||||
|
device.get().setGcmId(null);
|
||||||
|
accountsManager.update(account.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,8 +95,13 @@ public class FeedbackHandler implements Managed, Runnable {
|
||||||
if (device.isPresent()) {
|
if (device.isPresent()) {
|
||||||
if (event.getRegistrationId().equals(device.get().getApnId())) {
|
if (event.getRegistrationId().equals(device.get().getApnId())) {
|
||||||
logger.warn("APN Unregister APN ID matches!");
|
logger.warn("APN Unregister APN ID matches!");
|
||||||
device.get().setApnId(null);
|
if (device.get().getPushTimestamp() == 0 ||
|
||||||
accountsManager.update(account.get());
|
event.getTimestamp() < device.get().getPushTimestamp())
|
||||||
|
{
|
||||||
|
logger.warn("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.entities.SignedPreKey;
|
||||||
import org.whispersystems.textsecuregcm.util.Util;
|
import org.whispersystems.textsecuregcm.util.Util;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
public class Device {
|
public class Device {
|
||||||
|
|
||||||
public static final long MASTER_ID = 1;
|
public static final long MASTER_ID = 1;
|
||||||
|
@ -46,6 +44,9 @@ public class Device {
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private String apnId;
|
private String apnId;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
private long pushTimestamp;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private boolean fetchesMessages;
|
private boolean fetchesMessages;
|
||||||
|
|
||||||
|
@ -79,6 +80,10 @@ public class Device {
|
||||||
|
|
||||||
public void setApnId(String apnId) {
|
public void setApnId(String apnId) {
|
||||||
this.apnId = apnId;
|
this.apnId = apnId;
|
||||||
|
|
||||||
|
if (apnId != null) {
|
||||||
|
this.pushTimestamp = System.currentTimeMillis();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGcmId() {
|
public String getGcmId() {
|
||||||
|
@ -87,6 +92,10 @@ public class Device {
|
||||||
|
|
||||||
public void setGcmId(String gcmId) {
|
public void setGcmId(String gcmId) {
|
||||||
this.gcmId = gcmId;
|
this.gcmId = gcmId;
|
||||||
|
|
||||||
|
if (gcmId != null) {
|
||||||
|
this.pushTimestamp = System.currentTimeMillis();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
|
@ -145,4 +154,8 @@ public class Device {
|
||||||
public void setSignedPreKey(SignedPreKey signedPreKey) {
|
public void setSignedPreKey(SignedPreKey signedPreKey) {
|
||||||
this.signedPreKey = signedPreKey;
|
this.signedPreKey = signedPreKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getPushTimestamp() {
|
||||||
|
return pushTimestamp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue