Add backup support for remaining simple chat updates.

This commit is contained in:
Greyson Parrelli
2024-09-21 15:34:37 -04:00
parent 40ca94a7dd
commit 054b517a04
3 changed files with 28 additions and 6 deletions

View File

@@ -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? {

View File

@@ -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 -> {

View File

@@ -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;
}