mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-26 12:44:38 +00:00
Add internal debug setting to archive session.
This commit is contained in:
@@ -183,8 +183,8 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||
)
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from("Delete Session"),
|
||||
summary = DSLSettingsText.from("Deletes the session, essentially guaranteeing an encryption error if they send you a message."),
|
||||
title = DSLSettingsText.from("Delete Sessions"),
|
||||
summary = DSLSettingsText.from("Deletes all sessions with this recipient, essentially guaranteeing an encryption error if they send you a message."),
|
||||
onClick = {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle("Are you sure?")
|
||||
@@ -200,6 +200,20 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||
.show()
|
||||
}
|
||||
)
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from("Archive Sessions"),
|
||||
summary = DSLSettingsText.from("Archives all sessions associated with this recipient, causing you to create a new session the next time you send a message (while not causing decryption errors)."),
|
||||
onClick = {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle("Are you sure?")
|
||||
.setNegativeButton(android.R.string.cancel) { d, _ -> d.dismiss() }
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
AppDependencies.protocolStore.aci().sessions().archiveSessions(recipient.id)
|
||||
}
|
||||
.show()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
clickPref(
|
||||
|
||||
@@ -150,6 +150,30 @@ public class TextSecureSessionStore implements SignalServiceSessionStore {
|
||||
}
|
||||
}
|
||||
|
||||
public void archiveSessions(@NonNull RecipientId recipientId) {
|
||||
try (SignalSessionLock.Lock unused = ReentrantSessionLock.INSTANCE.acquire()) {
|
||||
Recipient recipient = Recipient.resolved(recipientId);
|
||||
|
||||
if (recipient.getHasAci()) {
|
||||
SignalProtocolAddress address = new SignalProtocolAddress(recipient.requireAci().toString(), 1);
|
||||
archiveSiblingSessions(address);
|
||||
archiveSession(address);
|
||||
}
|
||||
|
||||
if (recipient.getHasPni()) {
|
||||
SignalProtocolAddress address = new SignalProtocolAddress(recipient.requirePni().toString(), 1);
|
||||
archiveSiblingSessions(address);
|
||||
archiveSession(address);
|
||||
}
|
||||
|
||||
if (recipient.getHasE164()) {
|
||||
SignalProtocolAddress address = new SignalProtocolAddress(recipient.requireE164(), 1);
|
||||
archiveSiblingSessions(address);
|
||||
archiveSession(address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void archiveSiblingSessions(@NonNull SignalProtocolAddress address) {
|
||||
try (SignalSessionLock.Lock unused = ReentrantSessionLock.INSTANCE.acquire()) {
|
||||
List<SessionTable.SessionRow> sessions = SignalDatabase.sessions().getAllFor(accountId, address.getName());
|
||||
|
||||
Reference in New Issue
Block a user