mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-11 20:17:57 +00:00
Fix expiry timer millis conversion
This commit is contained in:
@@ -62,7 +62,7 @@ abstract class Message {
|
||||
expirationTimer = 0
|
||||
return this
|
||||
}
|
||||
if (config.isEnabled && config.expiryMode != null) {
|
||||
if (config.isEnabled) {
|
||||
expirationTimer = config.expiryMode.expirySeconds.toInt()
|
||||
lastDisappearingMessageChangeTimestamp = config.updatedTimestampMs
|
||||
if (ExpirationConfiguration.isNewConfigEnabled) {
|
||||
|
@@ -256,10 +256,10 @@ object MessageSender {
|
||||
val address = if (isSyncMessage && message is VisibleMessage) message.syncTarget else message.recipient
|
||||
storage.getThreadId(Address.fromSerialized(address!!)) ?: return null
|
||||
}
|
||||
val config = storage.getExpirationConfiguration(threadId) ?: return null
|
||||
val config = storage.getExpirationConfiguration(threadId)?.takeIf { it.isEnabled } ?: return null
|
||||
val expiryMode = config.expiryMode
|
||||
return if (config.isEnabled && (expiryMode is ExpiryMode.AfterSend || isSyncMessage)) {
|
||||
(expiryMode?.expirySeconds ?: 0L) * 1000L
|
||||
return if (expiryMode is ExpiryMode.AfterSend || isSyncMessage) {
|
||||
expiryMode.expiryMillis
|
||||
} else null
|
||||
}
|
||||
|
||||
|
@@ -303,12 +303,8 @@ fun MessageReceiver.updateExpiryIfNeeded(
|
||||
proto.lastDisappearingMessageChangeTimestamp
|
||||
)
|
||||
|
||||
val (shouldUpdateConfig, configToUse) =
|
||||
if (localConfig != null && localConfig.updatedTimestampMs > proto.lastDisappearingMessageChangeTimestamp) {
|
||||
false to localConfig
|
||||
} else {
|
||||
true to remoteConfig
|
||||
}
|
||||
val configToUse = localConfig?.takeIf { it.updatedTimestampMs > proto.lastDisappearingMessageChangeTimestamp } ?: remoteConfig
|
||||
val shouldUpdateConfig = configToUse == remoteConfig
|
||||
|
||||
// don't update any values for open groups
|
||||
if (recipient.isOpenGroupRecipient && type != null) throw MessageReceiver.Error.InvalidMessage
|
||||
@@ -325,12 +321,12 @@ fun MessageReceiver.updateExpiryIfNeeded(
|
||||
|
||||
// handle a delete after send expired fetch
|
||||
if (type == ExpirationType.DELETE_AFTER_SEND
|
||||
&& sentTime + configToUse.expiryMode.expirySeconds <= SnodeAPI.nowWithOffset) {
|
||||
&& sentTime + configToUse.expiryMode.expiryMillis <= SnodeAPI.nowWithOffset) {
|
||||
throw MessageReceiver.Error.ExpiredMessage
|
||||
}
|
||||
// handle a delete after read last known config value
|
||||
if (type == ExpirationType.DELETE_AFTER_READ
|
||||
&& sentTime + configToUse.expiryMode.expirySeconds <= storage.getLastSeen(threadID)) {
|
||||
&& sentTime + configToUse.expiryMode.expiryMillis <= storage.getLastSeen(threadID)) {
|
||||
throw MessageReceiver.Error.ExpiredMessage
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user