Disable inline message processing for internal users.
This commit is contained in:
parent
f06817f00d
commit
58a32c11ec
2 changed files with 19 additions and 29 deletions
|
@ -1,10 +1,5 @@
|
||||||
package org.thoughtcrime.securesms.crypto;
|
package org.thoughtcrime.securesms.crypto;
|
||||||
|
|
||||||
import net.sqlcipher.database.SQLiteDatabase;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
||||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
|
||||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
|
||||||
import org.whispersystems.signalservice.api.SignalSessionLock;
|
import org.whispersystems.signalservice.api.SignalSessionLock;
|
||||||
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
@ -24,26 +19,25 @@ public enum DatabaseSessionLock implements SignalSessionLock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Lock acquire() {
|
public Lock acquire() {
|
||||||
if (FeatureFlags.internalUser()) {
|
|
||||||
SQLiteDatabase db = DatabaseFactory.getInstance(ApplicationDependencies.getApplication()).getRawDatabase();
|
|
||||||
|
|
||||||
if (db.isDbLockedByCurrentThread()) {
|
|
||||||
return () -> {};
|
|
||||||
}
|
|
||||||
|
|
||||||
db.beginTransaction();
|
|
||||||
|
|
||||||
ownerThreadId = Thread.currentThread().getId();
|
|
||||||
|
|
||||||
return () -> {
|
|
||||||
ownerThreadId = -1;
|
|
||||||
db.setTransactionSuccessful();
|
|
||||||
db.endTransaction();
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
LEGACY_LOCK.lock();
|
LEGACY_LOCK.lock();
|
||||||
return LEGACY_LOCK::unlock;
|
return LEGACY_LOCK::unlock;
|
||||||
}
|
|
||||||
|
// TODO [greyson][db] Revisit after improving database locking
|
||||||
|
// SQLiteDatabase db = DatabaseFactory.getInstance(ApplicationDependencies.getApplication()).getRawDatabase();
|
||||||
|
//
|
||||||
|
// if (db.isDbLockedByCurrentThread()) {
|
||||||
|
// return () -> {};
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// db.beginTransaction();
|
||||||
|
//
|
||||||
|
// ownerThreadId = Thread.currentThread().getId();
|
||||||
|
//
|
||||||
|
// return () -> {
|
||||||
|
// ownerThreadId = -1;
|
||||||
|
// db.setTransactionSuccessful();
|
||||||
|
// db.endTransaction();
|
||||||
|
// };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -100,12 +100,8 @@ public class IncomingMessageProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable String processMessage(@NonNull SignalServiceEnvelope envelope) {
|
private @Nullable String processMessage(@NonNull SignalServiceEnvelope envelope) {
|
||||||
if (FeatureFlags.internalUser()) {
|
|
||||||
return processMessageInline(envelope);
|
|
||||||
} else {
|
|
||||||
return processMessageDeferred(envelope);
|
return processMessageDeferred(envelope);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private @Nullable String processMessageDeferred(@NonNull SignalServiceEnvelope envelope) {
|
private @Nullable String processMessageDeferred(@NonNull SignalServiceEnvelope envelope) {
|
||||||
Job job = new PushDecryptMessageJob(context, envelope);
|
Job job = new PushDecryptMessageJob(context, envelope);
|
||||||
|
|
Loading…
Add table
Reference in a new issue