Remove some indirect database reads from backup export.
This commit is contained in:
parent
cbb3c0911c
commit
341c474610
2 changed files with 12 additions and 15 deletions
|
@ -29,28 +29,26 @@ import org.whispersystems.signalservice.api.storage.StorageRecordProtoUtil.defau
|
||||||
import org.whispersystems.signalservice.api.subscriptions.SubscriberId
|
import org.whispersystems.signalservice.api.subscriptions.SubscriberId
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil
|
import org.whispersystems.signalservice.api.util.UuidUtil
|
||||||
import java.util.Currency
|
import java.util.Currency
|
||||||
import kotlin.jvm.optionals.getOrNull
|
|
||||||
|
|
||||||
object AccountDataProcessor {
|
object AccountDataProcessor {
|
||||||
|
|
||||||
fun export(db: SignalDatabase, emitter: BackupFrameEmitter) {
|
fun export(db: SignalDatabase, emitter: BackupFrameEmitter) {
|
||||||
val context = AppDependencies.application
|
val context = AppDependencies.application
|
||||||
|
|
||||||
// TODO [backup] Need to get it from the db snapshot
|
val selfId = db.recipientTable.getByAci(SignalStore.account().aci!!).get()
|
||||||
val self = Recipient.self().fresh()
|
val selfRecord = db.recipientTable.getRecordForSync(selfId)!!
|
||||||
val record = db.recipientTable.getRecordForSync(self.id)
|
|
||||||
|
|
||||||
// TODO [backup] Need to get it from the db snapshot
|
val donationCurrency = SignalStore.donationsValues().getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION)
|
||||||
val subscriber: InAppPaymentSubscriberRecord? = InAppPaymentsRepository.getSubscriber(InAppPaymentSubscriberRecord.Type.DONATION)
|
val donationSubscriber = SignalDatabase.inAppPaymentSubscribers.getByCurrencyCode(donationCurrency.currencyCode, InAppPaymentSubscriberRecord.Type.DONATION)
|
||||||
|
|
||||||
emitter.emit(
|
emitter.emit(
|
||||||
Frame(
|
Frame(
|
||||||
account = AccountData(
|
account = AccountData(
|
||||||
profileKey = self.profileKey?.toByteString() ?: EMPTY,
|
profileKey = selfRecord.profileKey?.toByteString() ?: EMPTY,
|
||||||
givenName = self.profileName.givenName,
|
givenName = selfRecord.signalProfileName.givenName,
|
||||||
familyName = self.profileName.familyName,
|
familyName = selfRecord.signalProfileName.familyName,
|
||||||
avatarUrlPath = self.profileAvatar ?: "",
|
avatarUrlPath = selfRecord.signalProfileAvatar ?: "",
|
||||||
username = self.username.getOrNull(),
|
username = selfRecord.username,
|
||||||
accountSettings = AccountData.AccountSettings(
|
accountSettings = AccountData.AccountSettings(
|
||||||
storyViewReceiptsEnabled = SignalStore.storyValues().viewedReceiptsEnabled,
|
storyViewReceiptsEnabled = SignalStore.storyValues().viewedReceiptsEnabled,
|
||||||
typingIndicators = TextSecurePreferences.isTypingIndicatorsEnabled(context),
|
typingIndicators = TextSecurePreferences.isTypingIndicatorsEnabled(context),
|
||||||
|
@ -71,8 +69,8 @@ object AccountDataProcessor {
|
||||||
hasCompletedUsernameOnboarding = SignalStore.uiHints().hasCompletedUsernameOnboarding()
|
hasCompletedUsernameOnboarding = SignalStore.uiHints().hasCompletedUsernameOnboarding()
|
||||||
),
|
),
|
||||||
donationSubscriberData = AccountData.SubscriberData(
|
donationSubscriberData = AccountData.SubscriberData(
|
||||||
subscriberId = subscriber?.subscriberId?.bytes?.toByteString() ?: defaultAccountRecord.subscriberId,
|
subscriberId = donationSubscriber?.subscriberId?.bytes?.toByteString() ?: defaultAccountRecord.subscriberId,
|
||||||
currencyCode = subscriber?.currency?.currencyCode ?: defaultAccountRecord.subscriberCurrencyCode,
|
currencyCode = donationSubscriber?.currency?.currencyCode ?: defaultAccountRecord.subscriberCurrencyCode,
|
||||||
manuallyCancelled = InAppPaymentsRepository.isUserManuallyCancelled(InAppPaymentSubscriberRecord.Type.DONATION)
|
manuallyCancelled = InAppPaymentsRepository.isUserManuallyCancelled(InAppPaymentSubscriberRecord.Type.DONATION)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -31,8 +31,7 @@ object RecipientBackupProcessor {
|
||||||
val TAG = Log.tag(RecipientBackupProcessor::class.java)
|
val TAG = Log.tag(RecipientBackupProcessor::class.java)
|
||||||
|
|
||||||
fun export(db: SignalDatabase, state: ExportState, emitter: BackupFrameEmitter) {
|
fun export(db: SignalDatabase, state: ExportState, emitter: BackupFrameEmitter) {
|
||||||
// TODO [backup] Need to get it from the db snapshot
|
val selfId = db.recipientTable.getByAci(SignalStore.account().aci!!).get().toLong()
|
||||||
val selfId = Recipient.self().id.toLong()
|
|
||||||
val releaseChannelId = SignalStore.releaseChannelValues().releaseChannelRecipientId
|
val releaseChannelId = SignalStore.releaseChannelValues().releaseChannelRecipientId
|
||||||
if (releaseChannelId != null) {
|
if (releaseChannelId != null) {
|
||||||
emitter.emit(
|
emitter.emit(
|
||||||
|
|
Loading…
Add table
Reference in a new issue