Add support for Contact.nickname in backup import/export.
This commit is contained in:
parent
ec3b40e2dd
commit
aa252b1733
4 changed files with 21 additions and 19 deletions
|
@ -79,7 +79,7 @@ class BackupCallLinkIterator(private val cursor: Cursor) : Iterator<BackupRecipi
|
||||||
} catch (e: ArithmeticException) {
|
} catch (e: ArithmeticException) {
|
||||||
Long.MAX_VALUE
|
Long.MAX_VALUE
|
||||||
},
|
},
|
||||||
restrictions = callLink.state.restrictions.toBackup()
|
restrictions = callLink.state.restrictions.toRemote()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ class BackupCallLinkIterator(private val cursor: Cursor) : Iterator<BackupRecipi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun CallLinkState.Restrictions.toBackup(): CallLink.Restrictions {
|
private fun CallLinkState.Restrictions.toRemote(): CallLink.Restrictions {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
CallLinkState.Restrictions.ADMIN_APPROVAL -> CallLink.Restrictions.ADMIN_APPROVAL
|
CallLinkState.Restrictions.ADMIN_APPROVAL -> CallLink.Restrictions.ADMIN_APPROVAL
|
||||||
CallLinkState.Restrictions.NONE -> CallLink.Restrictions.NONE
|
CallLinkState.Restrictions.NONE -> CallLink.Restrictions.NONE
|
||||||
|
|
|
@ -595,13 +595,13 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||||
|
|
||||||
val contacts = sharedContacts.map {
|
val contacts = sharedContacts.map {
|
||||||
ContactAttachment(
|
ContactAttachment(
|
||||||
name = it.name.toBackup(),
|
name = it.name.toRemote(),
|
||||||
avatar = (it.avatar?.attachment as? DatabaseAttachment)?.toRemoteMessageAttachment()?.pointer,
|
avatar = (it.avatar?.attachment as? DatabaseAttachment)?.toRemoteMessageAttachment()?.pointer,
|
||||||
organization = it.organization,
|
organization = it.organization,
|
||||||
number = it.phoneNumbers.map { phone ->
|
number = it.phoneNumbers.map { phone ->
|
||||||
ContactAttachment.Phone(
|
ContactAttachment.Phone(
|
||||||
value_ = phone.number,
|
value_ = phone.number,
|
||||||
type = phone.type.toBackup(),
|
type = phone.type.toRemote(),
|
||||||
label = phone.label
|
label = phone.label
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -609,12 +609,12 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||||
ContactAttachment.Email(
|
ContactAttachment.Email(
|
||||||
value_ = email.email,
|
value_ = email.email,
|
||||||
label = email.label,
|
label = email.label,
|
||||||
type = email.type.toBackup()
|
type = email.type.toRemote()
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
address = it.postalAddresses.map { address ->
|
address = it.postalAddresses.map { address ->
|
||||||
ContactAttachment.PostalAddress(
|
ContactAttachment.PostalAddress(
|
||||||
type = address.type.toBackup(),
|
type = address.type.toRemote(),
|
||||||
label = address.label,
|
label = address.label,
|
||||||
street = address.street,
|
street = address.street,
|
||||||
pobox = address.poBox,
|
pobox = address.poBox,
|
||||||
|
@ -629,21 +629,22 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||||
}
|
}
|
||||||
return ContactMessage(
|
return ContactMessage(
|
||||||
contact = contacts,
|
contact = contacts,
|
||||||
reactions = reactionRecords.toBackupReactions()
|
reactions = reactionRecords.toRemoteReactions()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Contact.Name.toBackup(): ContactAttachment.Name {
|
private fun Contact.Name.toRemote(): ContactAttachment.Name {
|
||||||
return ContactAttachment.Name(
|
return ContactAttachment.Name(
|
||||||
givenName = givenName,
|
givenName = givenName,
|
||||||
familyName = familyName,
|
familyName = familyName,
|
||||||
prefix = prefix,
|
prefix = prefix,
|
||||||
suffix = suffix,
|
suffix = suffix,
|
||||||
middleName = middleName
|
middleName = middleName,
|
||||||
|
nickname = nickname
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Contact.Phone.Type.toBackup(): ContactAttachment.Phone.Type {
|
private fun Contact.Phone.Type.toRemote(): ContactAttachment.Phone.Type {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
Contact.Phone.Type.HOME -> ContactAttachment.Phone.Type.HOME
|
Contact.Phone.Type.HOME -> ContactAttachment.Phone.Type.HOME
|
||||||
Contact.Phone.Type.MOBILE -> ContactAttachment.Phone.Type.MOBILE
|
Contact.Phone.Type.MOBILE -> ContactAttachment.Phone.Type.MOBILE
|
||||||
|
@ -652,7 +653,7 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Contact.Email.Type.toBackup(): ContactAttachment.Email.Type {
|
private fun Contact.Email.Type.toRemote(): ContactAttachment.Email.Type {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
Contact.Email.Type.HOME -> ContactAttachment.Email.Type.HOME
|
Contact.Email.Type.HOME -> ContactAttachment.Email.Type.HOME
|
||||||
Contact.Email.Type.MOBILE -> ContactAttachment.Email.Type.MOBILE
|
Contact.Email.Type.MOBILE -> ContactAttachment.Email.Type.MOBILE
|
||||||
|
@ -661,7 +662,7 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Contact.PostalAddress.Type.toBackup(): ContactAttachment.PostalAddress.Type {
|
private fun Contact.PostalAddress.Type.toRemote(): ContactAttachment.PostalAddress.Type {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
Contact.PostalAddress.Type.HOME -> ContactAttachment.PostalAddress.Type.HOME
|
Contact.PostalAddress.Type.HOME -> ContactAttachment.PostalAddress.Type.HOME
|
||||||
Contact.PostalAddress.Type.WORK -> ContactAttachment.PostalAddress.Type.WORK
|
Contact.PostalAddress.Type.WORK -> ContactAttachment.PostalAddress.Type.WORK
|
||||||
|
@ -693,7 +694,7 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||||
attachments = messageAttachments.toBackupAttachments(),
|
attachments = messageAttachments.toBackupAttachments(),
|
||||||
linkPreview = linkPreviews.map { it.toRemoteLinkPreview() },
|
linkPreview = linkPreviews.map { it.toRemoteLinkPreview() },
|
||||||
longText = longTextAttachment?.toRemoteFilePointer(mediaArchiveEnabled),
|
longText = longTextAttachment?.toRemoteFilePointer(mediaArchiveEnabled),
|
||||||
reactions = reactionRecords.toBackupReactions()
|
reactions = reactionRecords.toRemoteReactions()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,7 +750,7 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||||
emoji = stickerLocator.emoji,
|
emoji = stickerLocator.emoji,
|
||||||
data_ = this.toRemoteMessageAttachment().pointer
|
data_ = this.toRemoteMessageAttachment().pointer
|
||||||
),
|
),
|
||||||
reactions = reactions.toBackupReactions()
|
reactions = reactions.toRemoteReactions()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,14 +797,14 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||||
timestamp = this.timestamp,
|
timestamp = this.timestamp,
|
||||||
blockIndex = this.blockIndex,
|
blockIndex = this.blockIndex,
|
||||||
blockTimestamp = this.blockTimestamp,
|
blockTimestamp = this.blockTimestamp,
|
||||||
mobileCoinIdentification = this.paymentMetaData.mobileCoinTxoIdentification?.toBackup(),
|
mobileCoinIdentification = this.paymentMetaData.mobileCoinTxoIdentification?.toRemote(),
|
||||||
transaction = this.transaction?.toByteString(),
|
transaction = this.transaction?.toByteString(),
|
||||||
receipt = this.receipt?.toByteString()
|
receipt = this.receipt?.toByteString()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun PaymentMetaData.MobileCoinTxoIdentification.toBackup(): PaymentNotification.TransactionDetails.MobileCoinTxoIdentification {
|
private fun PaymentMetaData.MobileCoinTxoIdentification.toRemote(): PaymentNotification.TransactionDetails.MobileCoinTxoIdentification {
|
||||||
return PaymentNotification.TransactionDetails.MobileCoinTxoIdentification(
|
return PaymentNotification.TransactionDetails.MobileCoinTxoIdentification(
|
||||||
publicKey = this.publicKey,
|
publicKey = this.publicKey,
|
||||||
keyImages = this.keyImages
|
keyImages = this.keyImages
|
||||||
|
@ -873,7 +874,7 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun List<ReactionRecord>?.toBackupReactions(): List<Reaction> {
|
private fun List<ReactionRecord>?.toRemoteReactions(): List<Reaction> {
|
||||||
return this
|
return this
|
||||||
?.map {
|
?.map {
|
||||||
Reaction(
|
Reaction(
|
||||||
|
|
|
@ -1020,7 +1020,7 @@ class ChatItemImportInserter(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ContactAttachment.Name?.toLocal(): Contact.Name {
|
private fun ContactAttachment.Name?.toLocal(): Contact.Name {
|
||||||
return Contact.Name(this?.givenName, this?.familyName, this?.prefix, this?.suffix, this?.middleName, null)
|
return Contact.Name(this?.givenName, this?.familyName, this?.prefix, this?.suffix, this?.middleName, this?.nickname)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ContactAttachment.Phone.Type?.toLocal(): Contact.Phone.Type {
|
private fun ContactAttachment.Phone.Type?.toLocal(): Contact.Phone.Type {
|
||||||
|
|
|
@ -476,6 +476,7 @@ message ContactAttachment {
|
||||||
optional string prefix = 3;
|
optional string prefix = 3;
|
||||||
optional string suffix = 4;
|
optional string suffix = 4;
|
||||||
optional string middleName = 5;
|
optional string middleName = 5;
|
||||||
|
optional string nickname = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Phone {
|
message Phone {
|
||||||
|
@ -621,7 +622,7 @@ message FilePointer {
|
||||||
|
|
||||||
oneof locator {
|
oneof locator {
|
||||||
BackupLocator backupLocator = 1;
|
BackupLocator backupLocator = 1;
|
||||||
AttachmentLocator attachmentLocator = 2;
|
AttachmentLocator attachmentLocator= 2;
|
||||||
InvalidAttachmentLocator invalidAttachmentLocator = 3;
|
InvalidAttachmentLocator invalidAttachmentLocator = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue