Streamline export account data to not save to disk.

This commit is contained in:
Clark
2023-03-31 12:29:15 -04:00
committed by Alex Hart
parent 5e94c350ed
commit ad9337021c
9 changed files with 80 additions and 221 deletions

View File

@@ -26,7 +26,6 @@ import org.whispersystems.signalservice.api.push.PNI
import org.whispersystems.signalservice.api.push.ServiceIds
import org.whispersystems.signalservice.api.push.SignalServiceAddress
import java.security.SecureRandom
import kotlin.time.Duration.Companion.days
internal class AccountValues internal constructor(store: KeyValueStore) : SignalStoreValues(store) {
@@ -58,12 +57,6 @@ internal class AccountValues internal constructor(store: KeyValueStore) : Signal
private const val KEY_PNI_SIGNED_PREKEY_FAILURE_COUNT = "account.pni_signed_prekey_failure_count"
private const val KEY_PNI_NEXT_ONE_TIME_PREKEY_ID = "account.pni_next_one_time_prekey_id"
@VisibleForTesting
const val KEY_ACCOUNT_DATA_REPORT = "account.data_report"
@VisibleForTesting
const val KEY_ACCOUNT_DATA_REPORT_DOWNLOAD_TIME = "account.data_report_download_time"
@VisibleForTesting
const val KEY_E164 = "account.e164"
@@ -324,34 +317,6 @@ internal class AccountValues internal constructor(store: KeyValueStore) : Signal
}
}
val accountDataReport: String?
get() = getString(KEY_ACCOUNT_DATA_REPORT, null)
fun setAccountDataReport(report: String, downloadTime: Long) {
store.beginWrite()
.putString(KEY_ACCOUNT_DATA_REPORT, report)
.putLong(KEY_ACCOUNT_DATA_REPORT_DOWNLOAD_TIME, downloadTime)
.apply()
}
fun hasAccountDataReport(): Boolean = store.containsKey(KEY_ACCOUNT_DATA_REPORT)
fun clearOldAccountDataReport(): Boolean {
return if (hasAccountDataReport() && (getLong(KEY_ACCOUNT_DATA_REPORT_DOWNLOAD_TIME, 0) + 30.days.inWholeMilliseconds) < System.currentTimeMillis()) {
deleteAccountDataReport()
true
} else {
false
}
}
fun deleteAccountDataReport() {
store.beginWrite()
.remove(KEY_ACCOUNT_DATA_REPORT)
.remove(KEY_ACCOUNT_DATA_REPORT_DOWNLOAD_TIME)
.apply()
}
val deviceName: String?
get() = getString(KEY_DEVICE_NAME, null)