Fix expiry not added to community invites

This commit is contained in:
Andrew 2024-02-28 13:34:32 +10:30
parent 51f2c3557d
commit 22460df15e

View File

@ -38,6 +38,7 @@ import org.thoughtcrime.securesms.database.ThreadDatabase
import org.thoughtcrime.securesms.database.model.MessageRecord
import org.thoughtcrime.securesms.database.model.ThreadRecord
import org.thoughtcrime.securesms.dependencies.ConfigFactory
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
import javax.inject.Inject
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
@ -149,11 +150,12 @@ class DefaultConversationRepository @Inject constructor(
for (contact in contacts) {
val message = VisibleMessage()
message.sentTimestamp = SnodeAPI.nowWithOffset
val openGroupInvitation = OpenGroupInvitation()
openGroupInvitation.name = openGroup.name
openGroupInvitation.url = openGroup.joinURL
val openGroupInvitation = OpenGroupInvitation().apply {
name = openGroup.name
url = openGroup.joinURL
}
message.openGroupInvitation = openGroupInvitation
val expirationConfig = storage.getExpirationConfiguration(threadId)
val expirationConfig = DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(contact).let(storage::getExpirationConfiguration)
val expiresInMillis = expirationConfig?.expiryMode?.expiryMillis ?: 0
val expireStartedAt = if (expirationConfig?.expiryMode is ExpiryMode.AfterSend) message.sentTimestamp!! else 0
val outgoingTextMessage = OutgoingTextMessage.fromOpenGroupInvitation(