fix: activate the banner only if conversation is in expiring mode not none

This commit is contained in:
0x330a 2023-11-16 11:44:21 +11:00
parent 4ed5b57abd
commit d6ba78606e
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C
2 changed files with 10 additions and 6 deletions

View File

@ -1791,7 +1791,9 @@ open class Storage(
val recipientDb = DatabaseComponent.get(context).recipientDatabase()
recipientDb.setDisappearingState(recipient, disappearingState);
val currentLegacyRecipient = lokiDb.getLastLegacySenderAddress(recipientAddress)
val currentExpiry = getExpirationConfiguration(threadID)
if (disappearingState == DisappearingState.LEGACY
&& currentExpiry?.isEnabled == true
&& ExpirationConfiguration.isNewConfigEnabled) { // only set "this person is legacy" if new config enabled
lokiDb.setLastLegacySenderAddress(recipientAddress, messageSender)
} else if (messageSender == currentLegacyRecipient) {

View File

@ -283,12 +283,19 @@ fun MessageReceiver.updateExpiryIfNeeded(
val storage = MessagingModuleConfiguration.shared.storage
val sentTime = message.sentTimestamp ?: throw MessageReceiver.Error.InvalidMessage
if (!proto.hasLastDisappearingMessageChangeTimestamp()) return
val threadID =
storage.getThreadIdFor(message.sender!!, message.groupPublicKey, openGroupID, false)
?: throw MessageReceiver.Error.NoThread
val recipient = storage.getRecipientForThread(threadID) ?: throw MessageReceiver.Error.NoThread
if (!recipient.isLocalNumber) {
val disappearingState = if (proto.hasExpirationType()) Recipient.DisappearingState.UPDATED else Recipient.DisappearingState.LEGACY
storage.updateDisappearingState(message.sender!!, threadID, disappearingState)
}
if (!proto.hasLastDisappearingMessageChangeTimestamp()) return
val localConfig = storage.getExpirationConfiguration(threadID)
val durationSeconds = if (proto.hasExpirationTimer()) proto.expirationTimer else 0
@ -305,11 +312,6 @@ fun MessageReceiver.updateExpiryIfNeeded(
// don't update any values for open groups
if (recipient.isOpenGroupRecipient && type != null) throw MessageReceiver.Error.InvalidMessage
if (!recipient.isGroupRecipient && !recipient.isLocalNumber) {
val disappearingState = if (proto.hasExpirationType()) Recipient.DisappearingState.UPDATED else Recipient.DisappearingState.LEGACY
storage.updateDisappearingState(message.sender!!, threadID, disappearingState)
}
remoteConfig.takeIf { localConfig == null || it.updatedTimestampMs > localConfig.updatedTimestampMs }
?.let(storage::setExpirationConfiguration)