mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-21 19:48:29 +00:00
Add backup support for remaining simple chat updates.
This commit is contained in:
@@ -180,6 +180,15 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||
MessageTypes.isReportedSpam(record.type) -> {
|
||||
builder.updateMessage = simpleUpdate(SimpleChatUpdate.Type.REPORTED_SPAM)
|
||||
}
|
||||
MessageTypes.isMessageRequestAccepted(record.type) -> {
|
||||
builder.updateMessage = simpleUpdate(SimpleChatUpdate.Type.MESSAGE_REQUEST_ACCEPTED)
|
||||
}
|
||||
MessageTypes.isBlocked(record.type) -> {
|
||||
builder.updateMessage = simpleUpdate(SimpleChatUpdate.Type.BLOCKED)
|
||||
}
|
||||
MessageTypes.isUnblocked(record.type) -> {
|
||||
builder.updateMessage = simpleUpdate(SimpleChatUpdate.Type.UNBLOCKED)
|
||||
}
|
||||
MessageTypes.isExpirationTimerUpdate(record.type) -> {
|
||||
builder.updateMessage = ChatUpdateMessage(expirationTimerChange = ExpirationTimerChatUpdate(record.expiresIn))
|
||||
builder.expiresInMs = 0
|
||||
@@ -1058,7 +1067,10 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||
MessageTypes.isPaymentsActivated(this) ||
|
||||
MessageTypes.isPaymentsRequestToActivate(this) ||
|
||||
MessageTypes.isUnsupportedMessageType(this) ||
|
||||
MessageTypes.isReportedSpam(this)
|
||||
MessageTypes.isReportedSpam(this) ||
|
||||
MessageTypes.isMessageRequestAccepted(this) ||
|
||||
MessageTypes.isBlocked(this) ||
|
||||
MessageTypes.isUnblocked(this)
|
||||
}
|
||||
|
||||
private fun String.e164ToLong(): Long? {
|
||||
|
||||
@@ -419,8 +419,6 @@ class ChatItemImportInserter(
|
||||
return MessageInsert(contentValues, followUp)
|
||||
}
|
||||
|
||||
private class BatchInsert(val inserts: List<MessageInsert>, val query: SqlUtil.Query)
|
||||
|
||||
private fun ChatItem.toMessageContentValues(fromRecipientId: RecipientId, chatRecipientId: RecipientId, threadId: Long): ContentValues {
|
||||
val contentValues = ContentValues()
|
||||
|
||||
@@ -435,8 +433,8 @@ class ChatItemImportInserter(
|
||||
contentValues.putNull(MessageTable.LATEST_REVISION_ID)
|
||||
contentValues.putNull(MessageTable.ORIGINAL_MESSAGE_ID)
|
||||
contentValues.put(MessageTable.REVISION_NUMBER, 0)
|
||||
contentValues.put(MessageTable.EXPIRES_IN, this.expiresInMs ?: 0)
|
||||
contentValues.put(MessageTable.EXPIRE_STARTED, this.expireStartDate ?: 0)
|
||||
contentValues.put(MessageTable.EXPIRES_IN, this.expiresInMs)
|
||||
contentValues.put(MessageTable.EXPIRE_STARTED, this.expireStartDate)
|
||||
|
||||
if (this.outgoing != null) {
|
||||
val viewed = this.outgoing.sendStatus.any { it.viewed != null }
|
||||
@@ -632,7 +630,9 @@ class ChatItemImportInserter(
|
||||
SimpleChatUpdate.Type.PAYMENT_ACTIVATION_REQUEST -> MessageTypes.SPECIAL_TYPE_PAYMENTS_ACTIVATE_REQUEST or typeWithoutBase
|
||||
SimpleChatUpdate.Type.UNSUPPORTED_PROTOCOL_MESSAGE -> MessageTypes.UNSUPPORTED_MESSAGE_TYPE or typeWithoutBase
|
||||
SimpleChatUpdate.Type.REPORTED_SPAM -> MessageTypes.SPECIAL_TYPE_REPORTED_SPAM or typeWithoutBase
|
||||
else -> throw NotImplementedError()
|
||||
SimpleChatUpdate.Type.BLOCKED -> MessageTypes.SPECIAL_TYPE_BLOCKED or typeWithoutBase
|
||||
SimpleChatUpdate.Type.UNBLOCKED -> MessageTypes.SPECIAL_TYPE_UNBLOCKED or typeWithoutBase
|
||||
SimpleChatUpdate.Type.MESSAGE_REQUEST_ACCEPTED -> MessageTypes.SPECIAL_TYPE_MESSAGE_REQUEST_ACCEPTED or typeWithoutBase
|
||||
}
|
||||
}
|
||||
updateMessage.expirationTimerChange != null -> {
|
||||
|
||||
@@ -120,6 +120,8 @@ public interface MessageTypes {
|
||||
long SPECIAL_TYPE_MESSAGE_REQUEST_ACCEPTED = 0x600000000L;
|
||||
long SPECIAL_TYPE_PAYMENTS_ACTIVATED = 0x800000000L;
|
||||
long SPECIAL_TYPE_PAYMENTS_TOMBSTONE = 0x900000000L;
|
||||
long SPECIAL_TYPE_BLOCKED = 0xA00000000L;
|
||||
long SPECIAL_TYPE_UNBLOCKED = 0xB00000000L;
|
||||
|
||||
long IGNORABLE_TYPESMASK_WHEN_COUNTING = END_SESSION_BIT | KEY_EXCHANGE_IDENTITY_UPDATE_BIT | KEY_EXCHANGE_IDENTITY_VERIFIED_BIT;
|
||||
|
||||
@@ -155,6 +157,14 @@ public interface MessageTypes {
|
||||
return (type & SPECIAL_TYPES_MASK) == SPECIAL_TYPE_MESSAGE_REQUEST_ACCEPTED;
|
||||
}
|
||||
|
||||
static boolean isBlocked(long type) {
|
||||
return (type & SPECIAL_TYPES_MASK) == SPECIAL_TYPE_BLOCKED;
|
||||
}
|
||||
|
||||
static boolean isUnblocked(long type) {
|
||||
return (type & SPECIAL_TYPES_MASK) == SPECIAL_TYPE_UNBLOCKED;
|
||||
}
|
||||
|
||||
static boolean isDraftMessageType(long type) {
|
||||
return (type & BASE_TYPE_MASK) == BASE_DRAFT_TYPE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user