mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-09 08:54:29 +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
|
if (!proto.hasLastDisappearingMessageChangeTimestamp()) return
|
||||||
val threadID = storage.getOrCreateThreadIdFor(message.sender!!, message.groupPublicKey, openGroupID)
|
val threadID = storage.getOrCreateThreadIdFor(message.sender!!, message.groupPublicKey, openGroupID)
|
||||||
if (threadID <= 0) throw MessageReceiver.Error.NoThread
|
if (threadID <= 0) throw MessageReceiver.Error.NoThread
|
||||||
|
val recipient = storage.getRecipientForThread(threadID) ?: throw MessageReceiver.Error.NoThread
|
||||||
|
|
||||||
val localConfig = storage.getExpirationConfiguration(threadID)
|
val localConfig = storage.getExpirationConfiguration(threadID)
|
||||||
|
|
||||||
@ -257,8 +258,6 @@ fun MessageReceiver.updateExpiryIfNeeded(message: Message, proto: SignalServiceP
|
|||||||
true to remoteConfig
|
true to remoteConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
val recipient = storage.getRecipientForThread(threadID) ?: throw MessageReceiver.Error.NoThread
|
|
||||||
|
|
||||||
// don't update any values for open groups
|
// don't update any values for open groups
|
||||||
if (recipient.isOpenGroupRecipient && type != null) throw MessageReceiver.Error.InvalidMessage
|
if (recipient.isOpenGroupRecipient && type != null) throw MessageReceiver.Error.InvalidMessage
|
||||||
if ((recipient.isGroupRecipient || recipient.isLocalNumber)
|
if ((recipient.isGroupRecipient || recipient.isLocalNumber)
|
||||||
@ -267,6 +266,11 @@ fun MessageReceiver.updateExpiryIfNeeded(message: Message, proto: SignalServiceP
|
|||||||
throw MessageReceiver.Error.InvalidMessage
|
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
|
// handle a delete after send expired fetch
|
||||||
if (type == ExpirationType.DELETE_AFTER_SEND
|
if (type == ExpirationType.DELETE_AFTER_SEND
|
||||||
&& sentTime + configToUse.durationSeconds <= SnodeAPI.nowWithClockOffset) {
|
&& sentTime + configToUse.durationSeconds <= SnodeAPI.nowWithClockOffset) {
|
||||||
@ -279,8 +283,6 @@ fun MessageReceiver.updateExpiryIfNeeded(message: Message, proto: SignalServiceP
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shouldUpdateConfig) {
|
if (shouldUpdateConfig) {
|
||||||
val disappearingState = if (proto.hasExpirationType()) Recipient.DisappearingState.UPDATED else Recipient.DisappearingState.LEGACY
|
|
||||||
storage.updateDisappearingState(threadID, disappearingState)
|
|
||||||
storage.setExpirationConfiguration(configToUse)
|
storage.setExpirationConfiguration(configToUse)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user