mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-26 02:38:02 +01:00
Add support for "registrationId" session enforcement.
This commit is contained in:
@@ -48,11 +48,14 @@ public class Device implements Serializable {
|
||||
@JsonProperty
|
||||
private boolean fetchesMessages;
|
||||
|
||||
@JsonProperty
|
||||
private int registrationId;
|
||||
|
||||
public Device() {}
|
||||
|
||||
public Device(long id, String authToken, String salt,
|
||||
String signalingKey, String gcmId, String apnId,
|
||||
boolean fetchesMessages)
|
||||
boolean fetchesMessages, int registrationId)
|
||||
{
|
||||
this.id = id;
|
||||
this.authToken = authToken;
|
||||
@@ -61,6 +64,7 @@ public class Device implements Serializable {
|
||||
this.gcmId = gcmId;
|
||||
this.apnId = apnId;
|
||||
this.fetchesMessages = fetchesMessages;
|
||||
this.registrationId = registrationId;
|
||||
}
|
||||
|
||||
public String getApnId() {
|
||||
@@ -119,4 +123,12 @@ public class Device implements Serializable {
|
||||
public boolean isMaster() {
|
||||
return getId() == MASTER_ID;
|
||||
}
|
||||
|
||||
public int getRegistrationId() {
|
||||
return registrationId;
|
||||
}
|
||||
|
||||
public void setRegistrationId(int registrationId) {
|
||||
this.registrationId = registrationId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,14 +84,14 @@ public abstract class Keys {
|
||||
}
|
||||
|
||||
@Transaction(TransactionIsolationLevel.SERIALIZABLE)
|
||||
public Optional<PreKey> get(String number, long deviceId) {
|
||||
public Optional<UnstructuredPreKeyList> get(String number, long deviceId) {
|
||||
PreKey preKey = retrieveFirst(number, deviceId);
|
||||
|
||||
if (preKey != null && !preKey.isLastResort()) {
|
||||
removeKey(preKey.getId());
|
||||
}
|
||||
|
||||
if (preKey != null) return Optional.of(preKey);
|
||||
if (preKey != null) return Optional.of(new UnstructuredPreKeyList(preKey));
|
||||
else return Optional.absent();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user