mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-26 05:20:16 +00:00
Reorganize session store load/store operations.
This commit is contained in:
@@ -29,12 +29,13 @@ import org.whispersystems.libaxolotl.InvalidKeyException;
|
||||
import org.whispersystems.libaxolotl.InvalidMessageException;
|
||||
import org.whispersystems.libaxolotl.InvalidVersionException;
|
||||
import org.whispersystems.libaxolotl.protocol.PreKeyWhisperMessage;
|
||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||
import org.whispersystems.textsecure.push.IncomingPushMessage;
|
||||
import org.whispersystems.textsecure.push.PushMessageProtos.PushMessageContent;
|
||||
import org.whispersystems.textsecure.storage.InvalidKeyIdException;
|
||||
import org.whispersystems.textsecure.storage.RecipientDevice;
|
||||
import org.whispersystems.textsecure.storage.Session;
|
||||
import org.whispersystems.textsecure.storage.TextSecureSessionStore;
|
||||
import org.whispersystems.textsecure.util.Base64;
|
||||
|
||||
import ws.com.google.android.mms.MmsException;
|
||||
@@ -131,19 +132,12 @@ public class PushReceiver {
|
||||
|
||||
MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
|
||||
}
|
||||
} catch (InvalidKeyException e) {
|
||||
Log.w("PushReceiver", e);
|
||||
handleReceivedCorruptedKey(masterSecret, message, false);
|
||||
} catch (InvalidVersionException e) {
|
||||
Log.w("PushReceiver", e);
|
||||
handleReceivedCorruptedKey(masterSecret, message, true);
|
||||
} catch (InvalidKeyIdException e) {
|
||||
Log.w("PushReceiver", e);
|
||||
handleReceivedCorruptedKey(masterSecret, message, false);
|
||||
} catch (InvalidMessageException e) {
|
||||
Log.w("PushReceiver", e);
|
||||
handleReceivedCorruptedKey(masterSecret, message, false);
|
||||
} catch (RecipientFormattingException e) {
|
||||
} catch (InvalidKeyException | InvalidKeyIdException | InvalidMessageException |
|
||||
RecipientFormattingException e)
|
||||
{
|
||||
Log.w("PushReceiver", e);
|
||||
handleReceivedCorruptedKey(masterSecret, message, false);
|
||||
}
|
||||
@@ -189,7 +183,9 @@ public class PushReceiver {
|
||||
Pair<Long, Long> messageAndThreadId = database.insertMessageInbox(masterSecret, incomingEndSessionMessage);
|
||||
database.updateMessageBody(masterSecret, messageAndThreadId.first, messageContent.getBody());
|
||||
|
||||
Session.abortSessionFor(context, recipient);
|
||||
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
|
||||
sessionStore.deleteAll(recipient.getRecipientId());
|
||||
|
||||
KeyExchangeProcessor.broadcastSecurityUpdateEvent(context, messageAndThreadId.second);
|
||||
} catch (RecipientFormattingException e) {
|
||||
Log.w("PushReceiver", e);
|
||||
|
||||
@@ -42,8 +42,9 @@ import org.thoughtcrime.securesms.transport.SecureFallbackApprovalException;
|
||||
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
|
||||
import org.thoughtcrime.securesms.transport.UniversalTransport;
|
||||
import org.thoughtcrime.securesms.transport.UntrustedIdentityException;
|
||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||
import org.whispersystems.textsecure.storage.Session;
|
||||
import org.whispersystems.textsecure.storage.TextSecureSessionStore;
|
||||
|
||||
public class SmsSender {
|
||||
|
||||
@@ -61,7 +62,7 @@ public class SmsSender {
|
||||
if (SendReceiveService.SEND_SMS_ACTION.equals(intent.getAction())) {
|
||||
handleSendMessage(masterSecret, intent);
|
||||
} else if (SendReceiveService.SENT_SMS_ACTION.equals(intent.getAction())) {
|
||||
handleSentMessage(intent);
|
||||
handleSentMessage(masterSecret, intent);
|
||||
} else if (SendReceiveService.DELIVERED_SMS_ACTION.equals(intent.getAction())) {
|
||||
handleDeliveredMessage(intent);
|
||||
}
|
||||
@@ -116,7 +117,7 @@ public class SmsSender {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSentMessage(Intent intent) {
|
||||
private void handleSentMessage(MasterSecret masterSecret, Intent intent) {
|
||||
long messageId = intent.getLongExtra("message_id", -1);
|
||||
int result = intent.getIntExtra("ResultCode", -31337);
|
||||
boolean upgraded = intent.getBooleanExtra("upgraded", false);
|
||||
@@ -138,7 +139,8 @@ public class SmsSender {
|
||||
|
||||
if (record != null && record.isEndSession()) {
|
||||
Log.w("SmsSender", "Ending session...");
|
||||
Session.abortSessionFor(context, record.getIndividualRecipient());
|
||||
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
|
||||
sessionStore.deleteAll(record.getIndividualRecipient().getRecipientId());
|
||||
KeyExchangeProcessor.broadcastSecurityUpdateEvent(context, record.getThreadId());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user