Coerce disappear type to DaR for Calls and DataExtraction

This commit is contained in:
Andrew 2024-01-12 11:20:23 +10:30
parent 7b26de5bd6
commit 12edb9dff9
3 changed files with 10 additions and 10 deletions

View File

@ -56,7 +56,10 @@ abstract class Message {
dataMessage.group = groupProto.build()
}
fun SignalServiceProtos.Content.Builder.setExpirationConfigurationIfNeeded(threadId: Long?): SignalServiceProtos.Content.Builder {
fun SignalServiceProtos.Content.Builder.setExpirationConfigurationIfNeeded(
threadId: Long?,
coerceDisappearAfterSendToRead: Boolean = false
): SignalServiceProtos.Content.Builder {
val config = threadId?.let(MessagingModuleConfiguration.shared.storage::getExpirationConfiguration)
?: run {
expirationTimer = 0
@ -64,12 +67,10 @@ abstract class Message {
}
expirationTimer = config.expiryMode.expirySeconds.toInt()
lastDisappearingMessageChangeTimestamp = config.updatedTimestampMs
config.expiryMode.let { expiryMode ->
expirationType = when (expiryMode) {
is ExpiryMode.AfterSend -> ExpirationType.DELETE_AFTER_SEND
is ExpiryMode.AfterRead -> ExpirationType.DELETE_AFTER_READ
else -> ExpirationType.UNKNOWN
}
expirationType = when (config.expiryMode) {
is ExpiryMode.AfterSend -> if (coerceDisappearAfterSendToRead) ExpirationType.DELETE_AFTER_READ else ExpirationType.DELETE_AFTER_SEND
is ExpiryMode.AfterRead -> ExpirationType.DELETE_AFTER_READ
else -> ExpirationType.UNKNOWN
}
return this
}

View File

@ -82,8 +82,7 @@ class CallMessage(): ControlMessage() {
.setUuid(callId!!.toString())
val content = SignalServiceProtos.Content.newBuilder()
content.setExpirationConfigurationIfNeeded(threadID)
content.setExpirationConfigurationIfNeeded(threadID, true)
return content
.setCallMessage(callMessage)
.build()

View File

@ -64,7 +64,7 @@ class DataExtractionNotification() : ControlMessage() {
}
val contentProto = SignalServiceProtos.Content.newBuilder()
contentProto.dataExtractionNotification = dataExtractionNotification.build()
contentProto.setExpirationConfigurationIfNeeded(threadID)
contentProto.setExpirationConfigurationIfNeeded(threadID, true)
return contentProto.build()
} catch (e: Exception) {
Log.w(TAG, "Couldn't construct data extraction notification proto from: $this")