mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 16:03:39 +00:00
Coerce disappear type to DaR for Calls and DataExtraction
This commit is contained in:
parent
7b26de5bd6
commit
12edb9dff9
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user