mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +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_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) {
|
||||
AFTER_READ -> 12.hours
|
||||
@ -336,7 +336,7 @@ enum class ExpiryType(private val createMode: (Long) -> ExpiryMode) {
|
||||
}.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.AfterSend -> ExpiryType.AFTER_SEND
|
||||
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.Log
|
||||
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.model.MessageId
|
||||
import org.thoughtcrime.securesms.database.model.ReactionRecord
|
||||
@ -626,9 +627,6 @@ open class Storage(
|
||||
// Store the encryption key pair
|
||||
val keyPair = ECKeyPair(DjbECPublicKey(group.encPubKey), DjbECPrivateKey(group.encSecKey))
|
||||
addClosedGroupEncryptionKeyPair(keyPair, group.sessionId, SnodeAPI.nowWithOffset)
|
||||
// Set expiration timer
|
||||
val expireTimer = group.disappearingTimer
|
||||
setExpirationTimer(groupId, expireTimer.toInt())
|
||||
// Notify the PN server
|
||||
PushRegistryV1.subscribeGroup(group.sessionId, publicKey = localUserPublicKey)
|
||||
// Notify the user
|
||||
@ -1057,26 +1055,6 @@ open class Storage(
|
||||
.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>) {
|
||||
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);
|
||||
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) {
|
||||
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
|
||||
val encryptionKeyPair = Curve.generateKeyPair()
|
||||
storage.addClosedGroupEncryptionKeyPair(encryptionKeyPair, randomGroupPublicKey, System.currentTimeMillis())
|
||||
storage.setExpirationTimer(groupId, 0)
|
||||
storage.createInitialConfigGroup(randomGroupPublicKey, groupName, GroupUtil.createConfigMemberMap(members, setOf(adminUserId)), System.currentTimeMillis(), encryptionKeyPair)
|
||||
|
||||
// Add the group created message
|
||||
|
@ -152,7 +152,6 @@ interface StorageProtocol {
|
||||
fun getLatestClosedGroupEncryptionKeyPair(groupPublicKey: String): ECKeyPair?
|
||||
fun updateFormationTimestamp(groupID: String, formationTimestamp: Long)
|
||||
fun updateTimestampUpdated(groupID: String, updatedTimestamp: Long)
|
||||
fun setExpirationTimer(address: String, duration: Int)
|
||||
|
||||
// Groups
|
||||
fun getAllGroups(includeInactive: Boolean): List<GroupRecord>
|
||||
|
@ -17,4 +17,4 @@ data class ExpirationConfiguration(
|
||||
data class ExpirationDatabaseMetadata(
|
||||
val threadId: Long = -1,
|
||||
val updatedTimestampMs: Long
|
||||
)
|
||||
)
|
||||
|
@ -650,8 +650,6 @@ private fun handleNewClosedGroup(sender: String, sentTimestamp: Long, groupPubli
|
||||
// Store the encryption key pair
|
||||
storage.addClosedGroupEncryptionKeyPair(encryptionKeyPair, groupPublicKey, sentTimestamp)
|
||||
storage.createInitialConfigGroup(groupPublicKey, name, GroupUtil.createConfigMemberMap(members, admins), formationTimestamp, encryptionKeyPair)
|
||||
// Set expiration timer
|
||||
storage.setExpirationTimer(groupID, expireTimer)
|
||||
// Notify the PN server
|
||||
PushRegistryV1.register(device = MessagingModuleConfiguration.shared.device, publicKey = userPublicKey)
|
||||
// Notify the user
|
||||
|
Loading…
Reference in New Issue
Block a user