Log out sender key state for internal users.

This commit is contained in:
Greyson Parrelli
2021-11-01 12:32:14 -04:00
parent b8cf0cc1be
commit 3574be913a
7 changed files with 164 additions and 5 deletions

View File

@@ -10,11 +10,13 @@ import androidx.annotation.Nullable;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.whispersystems.libsignal.SignalProtocolAddress;
import org.whispersystems.signalservice.api.push.DistributionId;
import org.thoughtcrime.securesms.util.CursorUtil;
import org.thoughtcrime.securesms.util.SqlUtil;
import org.whispersystems.libsignal.groups.state.SenderKeyRecord;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import java.io.IOException;
@@ -110,6 +112,17 @@ public class SenderKeyDatabase extends Database {
db.delete(TABLE_NAME, query, args);
}
/**
* Get metadata for all sender keys created by the local user. Used for debugging.
*/
public Cursor getAllCreatedBySelf() {
SQLiteDatabase db = databaseHelper.getSignalReadableDatabase();
String query = ADDRESS + " = ?";
String[] args = SqlUtil.buildArgs(Recipient.self().requireAci());
return db.query(TABLE_NAME, new String[]{ ID, DISTRIBUTION_ID, CREATED_AT }, query, args, null, null, CREATED_AT + " DESC");
}
/**
* Deletes all database state.
*/

View File

@@ -157,4 +157,12 @@ public class SenderKeySharedDatabase extends Database {
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
db.delete(TABLE_NAME, null, null);
}
/**
* Gets the shared state of all of our sender keys. Used for debugging.
*/
public Cursor getAllSharedWithCursor() {
SQLiteDatabase db = databaseHelper.getSignalReadableDatabase();
return db.query(TABLE_NAME, null, null, null, null, null, DISTRIBUTION_ID + ", " + ADDRESS + ", " + DEVICE);
}
}