mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-28 10:47:46 +00:00
fix: activate the banner only if conversation is in expiring mode not none
This commit is contained in:
parent
4ed5b57abd
commit
d6ba78606e
@ -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) {
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user