Search in sources :

Example 1 with PushDatabase

use of org.thoughtcrime.securesms.database.PushDatabase in project Signal-Android by WhisperSystems.

the class PushDecryptJob method onRun.

@Override
public void onRun() throws NoSuchMessageException {
    if (!IdentityKeyUtil.hasIdentityKey(context)) {
        Log.w(TAG, "Skipping job, waiting for migration...");
        return;
    }
    MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);
    PushDatabase database = DatabaseFactory.getPushDatabase(context);
    SignalServiceEnvelope envelope = database.get(messageId);
    Optional<Long> optionalSmsMessageId = smsMessageId > 0 ? Optional.of(smsMessageId) : Optional.<Long>absent();
    MasterSecretUnion masterSecretUnion;
    if (masterSecret == null)
        masterSecretUnion = new MasterSecretUnion(MasterSecretUtil.getAsymmetricMasterSecret(context, null));
    else
        masterSecretUnion = new MasterSecretUnion(masterSecret);
    handleMessage(masterSecretUnion, envelope, optionalSmsMessageId);
    database.delete(messageId);
}
Also used : MasterSecret(org.thoughtcrime.securesms.crypto.MasterSecret) PushDatabase(org.thoughtcrime.securesms.database.PushDatabase) MasterSecretUnion(org.thoughtcrime.securesms.crypto.MasterSecretUnion) SignalServiceEnvelope(org.whispersystems.signalservice.api.messages.SignalServiceEnvelope)

Aggregations

MasterSecret (org.thoughtcrime.securesms.crypto.MasterSecret)1 MasterSecretUnion (org.thoughtcrime.securesms.crypto.MasterSecretUnion)1 PushDatabase (org.thoughtcrime.securesms.database.PushDatabase)1 SignalServiceEnvelope (org.whispersystems.signalservice.api.messages.SignalServiceEnvelope)1