mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-23 21:09:00 +00:00
Add expiration check on build freshness.
// FREEBIE
This commit is contained in:
@@ -31,7 +31,6 @@ import org.whispersystems.libaxolotl.NoSessionException;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import ws.com.google.android.mms.MmsException;
|
||||
@@ -43,7 +42,7 @@ import ws.com.google.android.mms.pdu.PduPart;
|
||||
import ws.com.google.android.mms.pdu.SendConf;
|
||||
import ws.com.google.android.mms.pdu.SendReq;
|
||||
|
||||
public class MmsSendJob extends MasterSecretJob {
|
||||
public class MmsSendJob extends SendJob {
|
||||
|
||||
private static final String TAG = MmsSendJob.class.getSimpleName();
|
||||
|
||||
@@ -66,7 +65,7 @@ public class MmsSendJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws MmsException, NoSuchMessageException, IOException {
|
||||
public void onSend(MasterSecret masterSecret) throws MmsException, NoSuchMessageException, IOException {
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
SendReq message = database.getOutgoingMessage(masterSecret, messageId);
|
||||
|
||||
|
@@ -66,7 +66,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws MmsException, IOException, NoSuchMessageException {
|
||||
public void onSend(MasterSecret masterSecret) throws MmsException, IOException, NoSuchMessageException {
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
SendReq message = database.getOutgoingMessage(masterSecret, messageId);
|
||||
|
||||
|
@@ -57,7 +57,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret)
|
||||
public void onSend(MasterSecret masterSecret)
|
||||
throws RetryLaterException, MmsException, NoSuchMessageException
|
||||
{
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
|
@@ -31,7 +31,7 @@ import ws.com.google.android.mms.ContentType;
|
||||
import ws.com.google.android.mms.pdu.PduPart;
|
||||
import ws.com.google.android.mms.pdu.SendReq;
|
||||
|
||||
public abstract class PushSendJob extends MasterSecretJob {
|
||||
public abstract class PushSendJob extends SendJob {
|
||||
|
||||
private static final String TAG = PushSendJob.class.getSimpleName();
|
||||
|
||||
|
@@ -51,7 +51,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws NoSuchMessageException, RetryLaterException {
|
||||
public void onSend(MasterSecret masterSecret) throws NoSuchMessageException, RetryLaterException {
|
||||
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
|
||||
SmsMessageRecord record = database.getMessage(masterSecret, messageId);
|
||||
String destination = record.getIndividualRecipient().getNumber();
|
||||
|
29
src/org/thoughtcrime/securesms/jobs/SendJob.java
Normal file
29
src/org/thoughtcrime/securesms/jobs/SendJob.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.thoughtcrime.securesms.BuildConfig;
|
||||
import org.thoughtcrime.securesms.TextSecureExpiredException;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.jobqueue.JobParameters;
|
||||
|
||||
public abstract class SendJob extends MasterSecretJob {
|
||||
|
||||
public SendJob(Context context, JobParameters parameters) {
|
||||
super(context, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onRun(MasterSecret masterSecret) throws Exception {
|
||||
if (!Util.isBuildFresh()) {
|
||||
throw new TextSecureExpiredException(String.format("TextSecure expired (build %d, now %d)",
|
||||
BuildConfig.BUILD_TIMESTAMP,
|
||||
System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
onSend(masterSecret);
|
||||
}
|
||||
|
||||
protected abstract void onSend(MasterSecret masterSecret) throws Exception;
|
||||
}
|
@@ -31,7 +31,7 @@ import org.whispersystems.libaxolotl.NoSessionException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SmsSendJob extends MasterSecretJob {
|
||||
public class SmsSendJob extends SendJob {
|
||||
|
||||
private static final String TAG = SmsSendJob.class.getSimpleName();
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SmsSendJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws NoSuchMessageException {
|
||||
public void onSend(MasterSecret masterSecret) throws NoSuchMessageException {
|
||||
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
|
||||
SmsMessageRecord record = database.getMessage(masterSecret, messageId);
|
||||
|
||||
|
Reference in New Issue
Block a user