diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt index ec0452bedd..d486fdcaf1 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt @@ -238,6 +238,7 @@ fun MessageReceiver.updateExpiryIfNeeded(message: Message, proto: SignalServiceP if (!proto.hasLastDisappearingMessageChangeTimestamp()) return val threadID = storage.getOrCreateThreadIdFor(message.sender!!, message.groupPublicKey, openGroupID) if (threadID <= 0) throw MessageReceiver.Error.NoThread + val recipient = storage.getRecipientForThread(threadID) ?: throw MessageReceiver.Error.NoThread val localConfig = storage.getExpirationConfiguration(threadID) @@ -257,8 +258,6 @@ fun MessageReceiver.updateExpiryIfNeeded(message: Message, proto: SignalServiceP true to remoteConfig } - val recipient = storage.getRecipientForThread(threadID) ?: throw MessageReceiver.Error.NoThread - // don't update any values for open groups if (recipient.isOpenGroupRecipient && type != null) throw MessageReceiver.Error.InvalidMessage if ((recipient.isGroupRecipient || recipient.isLocalNumber) @@ -267,6 +266,11 @@ fun MessageReceiver.updateExpiryIfNeeded(message: Message, proto: SignalServiceP throw MessageReceiver.Error.InvalidMessage } + if (!recipient.isGroupRecipient && !recipient.isLocalNumber) { + val disappearingState = if (proto.hasExpirationType()) Recipient.DisappearingState.UPDATED else Recipient.DisappearingState.LEGACY + storage.updateDisappearingState(threadID, disappearingState) + } + // handle a delete after send expired fetch if (type == ExpirationType.DELETE_AFTER_SEND && sentTime + configToUse.durationSeconds <= SnodeAPI.nowWithClockOffset) { @@ -279,8 +283,6 @@ fun MessageReceiver.updateExpiryIfNeeded(message: Message, proto: SignalServiceP } if (shouldUpdateConfig) { - val disappearingState = if (proto.hasExpirationType()) Recipient.DisappearingState.UPDATED else Recipient.DisappearingState.LEGACY - storage.updateDisappearingState(threadID, disappearingState) storage.setExpirationConfiguration(configToUse) }