mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Archive sessions on 409/410 instead of deleting them.
This commit is contained in:
@@ -14,15 +14,17 @@ import org.whispersystems.libsignal.state.SessionStore;
|
||||
import org.whispersystems.libsignal.state.SignalProtocolStore;
|
||||
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
||||
import org.whispersystems.libsignal.state.SignedPreKeyStore;
|
||||
import org.whispersystems.signalservice.api.SignalServiceProtocolStore;
|
||||
import org.whispersystems.signalservice.api.SignalServiceSessionStore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SignalProtocolStoreImpl implements SignalProtocolStore {
|
||||
public class SignalProtocolStoreImpl implements SignalServiceProtocolStore {
|
||||
|
||||
private final PreKeyStore preKeyStore;
|
||||
private final SignedPreKeyStore signedPreKeyStore;
|
||||
private final IdentityKeyStore identityKeyStore;
|
||||
private final SessionStore sessionStore;
|
||||
private final PreKeyStore preKeyStore;
|
||||
private final SignedPreKeyStore signedPreKeyStore;
|
||||
private final IdentityKeyStore identityKeyStore;
|
||||
private final SignalServiceSessionStore sessionStore;
|
||||
|
||||
public SignalProtocolStoreImpl(Context context) {
|
||||
this.preKeyStore = new TextSecurePreKeyStore(context);
|
||||
@@ -106,6 +108,11 @@ public class SignalProtocolStoreImpl implements SignalProtocolStore {
|
||||
sessionStore.deleteAllSessions(number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void archiveSession(SignalProtocolAddress address) {
|
||||
sessionStore.archiveSession(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException {
|
||||
return signedPreKeyStore.loadSignedPreKey(signedPreKeyId);
|
||||
|
||||
@@ -12,12 +12,12 @@ import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||
import org.whispersystems.libsignal.protocol.CiphertextMessage;
|
||||
import org.whispersystems.libsignal.state.SessionRecord;
|
||||
import org.whispersystems.libsignal.state.SessionStore;
|
||||
import org.whispersystems.signalservice.api.SignalServiceSessionStore;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class TextSecureSessionStore implements SessionStore {
|
||||
public class TextSecureSessionStore implements SignalServiceSessionStore {
|
||||
|
||||
private static final String TAG = TextSecureSessionStore.class.getSimpleName();
|
||||
|
||||
@@ -103,6 +103,16 @@ public class TextSecureSessionStore implements SessionStore {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void archiveSession(SignalProtocolAddress address) {
|
||||
synchronized (FILE_LOCK) {
|
||||
if (DatabaseFactory.getRecipientDatabase(context).containsPhoneOrUuid(address.getName())) {
|
||||
RecipientId recipientId = Recipient.external(context, address.getName()).getId();
|
||||
archiveSession(recipientId, address.getDeviceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void archiveSession(@NonNull RecipientId recipientId, int deviceId) {
|
||||
synchronized (FILE_LOCK) {
|
||||
SessionRecord session = DatabaseFactory.getSessionDatabase(context).load(recipientId, deviceId);
|
||||
|
||||
Reference in New Issue
Block a user