mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-02 14:35:21 +00:00
Remove Storage#setExpirationTimer
This commit is contained in:
parent
cdb7a5f5d6
commit
ba0ca7d260
@ -328,7 +328,7 @@ enum class ExpiryType(private val createMode: (Long) -> ExpiryMode) {
|
|||||||
AFTER_SEND(ExpiryMode::AfterSend),
|
AFTER_SEND(ExpiryMode::AfterSend),
|
||||||
AFTER_READ(ExpiryMode::AfterRead);
|
AFTER_READ(ExpiryMode::AfterRead);
|
||||||
|
|
||||||
fun mode(seconds: Long) = createMode(seconds)
|
fun mode(seconds: Long) = if (seconds != 0L) createMode(seconds) else ExpiryMode.NONE
|
||||||
|
|
||||||
fun defaultMode() = when(this) {
|
fun defaultMode() = when(this) {
|
||||||
AFTER_READ -> 12.hours
|
AFTER_READ -> 12.hours
|
||||||
@ -336,7 +336,7 @@ enum class ExpiryType(private val createMode: (Long) -> ExpiryMode) {
|
|||||||
}.inWholeSeconds.let(::mode)
|
}.inWholeSeconds.let(::mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val ExpiryMode.type: ExpiryType get() = when(this) {
|
val ExpiryMode.type: ExpiryType get() = when(this) {
|
||||||
is ExpiryMode.Legacy -> ExpiryType.LEGACY
|
is ExpiryMode.Legacy -> ExpiryType.LEGACY
|
||||||
is ExpiryMode.AfterSend -> ExpiryType.AFTER_SEND
|
is ExpiryMode.AfterSend -> ExpiryType.AFTER_SEND
|
||||||
is ExpiryMode.AfterRead -> ExpiryType.AFTER_READ
|
is ExpiryMode.AfterRead -> ExpiryType.AFTER_READ
|
||||||
|
@ -78,6 +78,7 @@ import org.session.libsignal.utilities.IdPrefix
|
|||||||
import org.session.libsignal.utilities.KeyHelper
|
import org.session.libsignal.utilities.KeyHelper
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import org.session.libsignal.utilities.guava.Optional
|
import org.session.libsignal.utilities.guava.Optional
|
||||||
|
import org.thoughtcrime.securesms.conversation.expiration.type
|
||||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||||
import org.thoughtcrime.securesms.database.model.MessageId
|
import org.thoughtcrime.securesms.database.model.MessageId
|
||||||
import org.thoughtcrime.securesms.database.model.ReactionRecord
|
import org.thoughtcrime.securesms.database.model.ReactionRecord
|
||||||
@ -626,9 +627,6 @@ open class Storage(
|
|||||||
// Store the encryption key pair
|
// Store the encryption key pair
|
||||||
val keyPair = ECKeyPair(DjbECPublicKey(group.encPubKey), DjbECPrivateKey(group.encSecKey))
|
val keyPair = ECKeyPair(DjbECPublicKey(group.encPubKey), DjbECPrivateKey(group.encSecKey))
|
||||||
addClosedGroupEncryptionKeyPair(keyPair, group.sessionId, SnodeAPI.nowWithOffset)
|
addClosedGroupEncryptionKeyPair(keyPair, group.sessionId, SnodeAPI.nowWithOffset)
|
||||||
// Set expiration timer
|
|
||||||
val expireTimer = group.disappearingTimer
|
|
||||||
setExpirationTimer(groupId, expireTimer.toInt())
|
|
||||||
// Notify the PN server
|
// Notify the PN server
|
||||||
PushRegistryV1.subscribeGroup(group.sessionId, publicKey = localUserPublicKey)
|
PushRegistryV1.subscribeGroup(group.sessionId, publicKey = localUserPublicKey)
|
||||||
// Notify the user
|
// Notify the user
|
||||||
@ -1057,26 +1055,6 @@ open class Storage(
|
|||||||
.updateTimestampUpdated(groupID, updatedTimestamp)
|
.updateTimestampUpdated(groupID, updatedTimestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setExpirationTimer(address: String, duration: Int) {
|
|
||||||
val recipient = Recipient.from(context, fromSerialized(address), false)
|
|
||||||
val threadId = DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(recipient)
|
|
||||||
DatabaseComponent.get(context).expirationConfigurationDatabase().setExpirationConfiguration(
|
|
||||||
ExpirationConfiguration(threadId, ExpiryMode.AfterSend(duration.toLong()), SnodeAPI.nowWithOffset)
|
|
||||||
)
|
|
||||||
if (recipient.isContactRecipient && !recipient.isLocalNumber) {
|
|
||||||
configFactory.contacts?.upsertContact(address) {
|
|
||||||
this.expiryMode = if (duration != 0) {
|
|
||||||
ExpiryMode.AfterRead(duration.toLong())
|
|
||||||
} else { // = 0 / delete
|
|
||||||
ExpiryMode.NONE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (configFactory.contacts?.needsPush() == true) {
|
|
||||||
ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setServerCapabilities(server: String, capabilities: List<String>) {
|
override fun setServerCapabilities(server: String, capabilities: List<String>) {
|
||||||
return DatabaseComponent.get(context).lokiAPIDatabase().setServerCapabilities(server, capabilities)
|
return DatabaseComponent.get(context).lokiAPIDatabase().setServerCapabilities(server, capabilities)
|
||||||
}
|
}
|
||||||
|
@ -161,8 +161,6 @@ public class ExpiringMessageManager implements SSKEnvironment.MessageExpirationM
|
|||||||
|
|
||||||
OutgoingExpirationUpdateMessage timerUpdateMessage = new OutgoingExpirationUpdateMessage(recipient, sentTimestamp, duration * 1000L, expireStartedAt, groupId);
|
OutgoingExpirationUpdateMessage timerUpdateMessage = new OutgoingExpirationUpdateMessage(recipient, sentTimestamp, duration * 1000L, expireStartedAt, groupId);
|
||||||
mmsDatabase.insertSecureDecryptedMessageOutbox(timerUpdateMessage, message.getThreadID(), sentTimestamp, true);
|
mmsDatabase.insertSecureDecryptedMessageOutbox(timerUpdateMessage, message.getThreadID(), sentTimestamp, true);
|
||||||
//set the timer to the conversation
|
|
||||||
MessagingModuleConfiguration.getShared().getStorage().setExpirationTimer(recipient.getAddress().serialize(), duration);
|
|
||||||
} catch (MmsException | IOException ioe) {
|
} catch (MmsException | IOException ioe) {
|
||||||
Log.e("Loki", "Failed to insert expiration update message.", ioe);
|
Log.e("Loki", "Failed to insert expiration update message.", ioe);
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,6 @@ object MockDataGenerator {
|
|||||||
// Add the group to the user's set of public keys to poll for and store the key pair
|
// Add the group to the user's set of public keys to poll for and store the key pair
|
||||||
val encryptionKeyPair = Curve.generateKeyPair()
|
val encryptionKeyPair = Curve.generateKeyPair()
|
||||||
storage.addClosedGroupEncryptionKeyPair(encryptionKeyPair, randomGroupPublicKey, System.currentTimeMillis())
|
storage.addClosedGroupEncryptionKeyPair(encryptionKeyPair, randomGroupPublicKey, System.currentTimeMillis())
|
||||||
storage.setExpirationTimer(groupId, 0)
|
|
||||||
storage.createInitialConfigGroup(randomGroupPublicKey, groupName, GroupUtil.createConfigMemberMap(members, setOf(adminUserId)), System.currentTimeMillis(), encryptionKeyPair)
|
storage.createInitialConfigGroup(randomGroupPublicKey, groupName, GroupUtil.createConfigMemberMap(members, setOf(adminUserId)), System.currentTimeMillis(), encryptionKeyPair)
|
||||||
|
|
||||||
// Add the group created message
|
// Add the group created message
|
||||||
|
@ -152,7 +152,6 @@ interface StorageProtocol {
|
|||||||
fun getLatestClosedGroupEncryptionKeyPair(groupPublicKey: String): ECKeyPair?
|
fun getLatestClosedGroupEncryptionKeyPair(groupPublicKey: String): ECKeyPair?
|
||||||
fun updateFormationTimestamp(groupID: String, formationTimestamp: Long)
|
fun updateFormationTimestamp(groupID: String, formationTimestamp: Long)
|
||||||
fun updateTimestampUpdated(groupID: String, updatedTimestamp: Long)
|
fun updateTimestampUpdated(groupID: String, updatedTimestamp: Long)
|
||||||
fun setExpirationTimer(address: String, duration: Int)
|
|
||||||
|
|
||||||
// Groups
|
// Groups
|
||||||
fun getAllGroups(includeInactive: Boolean): List<GroupRecord>
|
fun getAllGroups(includeInactive: Boolean): List<GroupRecord>
|
||||||
|
@ -650,8 +650,6 @@ private fun handleNewClosedGroup(sender: String, sentTimestamp: Long, groupPubli
|
|||||||
// Store the encryption key pair
|
// Store the encryption key pair
|
||||||
storage.addClosedGroupEncryptionKeyPair(encryptionKeyPair, groupPublicKey, sentTimestamp)
|
storage.addClosedGroupEncryptionKeyPair(encryptionKeyPair, groupPublicKey, sentTimestamp)
|
||||||
storage.createInitialConfigGroup(groupPublicKey, name, GroupUtil.createConfigMemberMap(members, admins), formationTimestamp, encryptionKeyPair)
|
storage.createInitialConfigGroup(groupPublicKey, name, GroupUtil.createConfigMemberMap(members, admins), formationTimestamp, encryptionKeyPair)
|
||||||
// Set expiration timer
|
|
||||||
storage.setExpirationTimer(groupID, expireTimer)
|
|
||||||
// Notify the PN server
|
// Notify the PN server
|
||||||
PushRegistryV1.register(device = MessagingModuleConfiguration.shared.device, publicKey = userPublicKey)
|
PushRegistryV1.register(device = MessagingModuleConfiguration.shared.device, publicKey = userPublicKey)
|
||||||
// Notify the user
|
// Notify the user
|
||||||
|
Loading…
Reference in New Issue
Block a user