Don't shorten ttl of closedGroupControlMessage

This commit is contained in:
Andrew 2024-02-21 01:16:05 +10:30
parent f5121770ec
commit 39df560f0c

View File

@ -252,19 +252,18 @@ object MessageSender {
return promise return promise
} }
private fun getSpecifiedTtl(message: Message, isSyncMessage: Boolean): Long? { private fun getSpecifiedTtl(
val storage = MessagingModuleConfiguration.shared.storage message: Message,
val threadId = message.threadID isSyncMessage: Boolean
?: run { ): Long? = message.takeUnless { it is ClosedGroupControlMessage }?.run {
val address = if (isSyncMessage && message is VisibleMessage) message.syncTarget else message.recipient threadID ?: (if (isSyncMessage && this is VisibleMessage) syncTarget else recipient)
storage.getThreadId(Address.fromSerialized(address!!)) ?: return null ?.let(Address.Companion::fromSerialized)
} ?.let(MessagingModuleConfiguration.shared.storage::getThreadId)
val config = storage.getExpirationConfiguration(threadId)?.takeIf { it.isEnabled } ?: return null }?.let(MessagingModuleConfiguration.shared.storage::getExpirationConfiguration)
val expiryMode = config.expiryMode ?.takeIf { it.isEnabled }
return if (expiryMode is ExpiryMode.AfterSend || isSyncMessage) { ?.expiryMode
expiryMode.expiryMillis ?.takeIf { it is ExpiryMode.AfterSend || isSyncMessage }
} else null ?.expiryMillis
}
// Open Groups // Open Groups
private fun sendToOpenGroupDestination(destination: Destination, message: Message): Promise<Unit, Exception> { private fun sendToOpenGroupDestination(destination: Destination, message: Message): Promise<Unit, Exception> {