diff --git a/libsession/src/main/java/org/session/libsession/messaging/messages/Message.kt b/libsession/src/main/java/org/session/libsession/messaging/messages/Message.kt index 988789b2ca..bfd5508643 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/messages/Message.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/messages/Message.kt @@ -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 } diff --git a/libsession/src/main/java/org/session/libsession/messaging/messages/control/CallMessage.kt b/libsession/src/main/java/org/session/libsession/messaging/messages/control/CallMessage.kt index 7b640b7822..ec7cade1e1 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/messages/control/CallMessage.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/messages/control/CallMessage.kt @@ -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() diff --git a/libsession/src/main/java/org/session/libsession/messaging/messages/control/DataExtractionNotification.kt b/libsession/src/main/java/org/session/libsession/messaging/messages/control/DataExtractionNotification.kt index 99ca047bbc..9bea2fbcc4 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/messages/control/DataExtractionNotification.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/messages/control/DataExtractionNotification.kt @@ -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")