Don't enqueue duplicate PushDecryptMessageJobs.
This commit is contained in:
parent
ea8e13b1c8
commit
1cd6b58ece
2 changed files with 13 additions and 6 deletions
|
@ -50,7 +50,7 @@ public class PushDatabase extends Database {
|
|||
Optional<Long> messageId = find(envelope);
|
||||
|
||||
if (messageId.isPresent()) {
|
||||
return messageId.get();
|
||||
return -1;
|
||||
} else {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(TYPE, envelope.getType());
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.jobmanager.JobManager;
|
|||
import org.thoughtcrime.securesms.jobs.PushDecryptMessageJob;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
@ -90,15 +91,21 @@ public class IncomingMessageProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
private @NonNull String processMessage(@NonNull SignalServiceEnvelope envelope) {
|
||||
private @Nullable String processMessage(@NonNull SignalServiceEnvelope envelope) {
|
||||
Log.i(TAG, "Received message. Inserting in PushDatabase.");
|
||||
|
||||
long id = pushDatabase.insert(envelope);
|
||||
PushDecryptMessageJob job = new PushDecryptMessageJob(context, id);
|
||||
long id = pushDatabase.insert(envelope);
|
||||
|
||||
jobManager.add(job);
|
||||
if (id > 0) {
|
||||
PushDecryptMessageJob job = new PushDecryptMessageJob(context, id);
|
||||
|
||||
return job.getId();
|
||||
jobManager.add(job);
|
||||
|
||||
return job.getId();
|
||||
} else {
|
||||
Log.w(TAG, "The envelope was already present in the PushDatabase.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void processReceipt(@NonNull SignalServiceEnvelope envelope) {
|
||||
|
|
Loading…
Add table
Reference in a new issue