mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-28 10:47:46 +00:00
refactor: move the legacy/updated expiring and add extra condition it is only set from one on one conversations (non self-send)
This commit is contained in:
parent
f0aba3a973
commit
dd51c9ab41
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user