Fix expiry mode application to Message

This commit is contained in:
Andrew
2024-02-09 11:13:10 +10:30
parent 181dd15028
commit 637b7f8249
5 changed files with 25 additions and 25 deletions

View File

@@ -94,12 +94,6 @@ fun SignalServiceProtos.Content.expiryMode(): ExpiryMode =
/**
* Apply ExpiryMode from the current setting.
*/
inline fun <reified M: Message> M.applyExpiryMode(): M {
val address = Address.fromSerialized(sender ?: return this)
MessagingModuleConfiguration.shared.storage.getThreadId(address)?.let(::applyExpiryMode)
return this
}
inline fun <reified M: Message> M.applyExpiryMode(thread: Long): M {
val storage = MessagingModuleConfiguration.shared.storage
expiryMode = storage.getExpirationConfiguration(thread)?.expiryMode?.coerceSendToRead(coerceDisappearAfterSendToRead) ?: ExpiryMode.NONE

View File

@@ -42,21 +42,21 @@ class CallMessage(): ControlMessage() {
listOf(),
listOf(),
callId
).applyExpiryMode()
)
fun preOffer(callId: UUID) = CallMessage(PRE_OFFER,
listOf(),
listOf(),
listOf(),
callId
).applyExpiryMode()
)
fun offer(sdp: String, callId: UUID) = CallMessage(OFFER,
listOf(sdp),
listOf(),
listOf(),
callId
).applyExpiryMode()
)
fun endCall(callId: UUID) = CallMessage(END_CALL, emptyList(), emptyList(), emptyList(), callId)

View File

@@ -471,8 +471,8 @@ object MessageSender {
@JvmStatic
fun send(message: Message, address: Address) {
message.applyExpiryMode()
val threadID = MessagingModuleConfiguration.shared.storage.getThreadId(address)
threadID?.let(message::applyExpiryMode)
message.threadID = threadID
val destination = Destination.from(address)
val job = MessageSendJob(message, destination)