|
|
@ -7,7 +7,6 @@ import network.loki.messenger.libsession_util.Contacts
|
|
|
|
import network.loki.messenger.libsession_util.ConversationVolatileConfig
|
|
|
|
import network.loki.messenger.libsession_util.ConversationVolatileConfig
|
|
|
|
import network.loki.messenger.libsession_util.UserGroupsConfig
|
|
|
|
import network.loki.messenger.libsession_util.UserGroupsConfig
|
|
|
|
import network.loki.messenger.libsession_util.UserProfile
|
|
|
|
import network.loki.messenger.libsession_util.UserProfile
|
|
|
|
import org.session.libsession.snode.SnodeAPI
|
|
|
|
|
|
|
|
import org.session.libsession.utilities.ConfigFactoryProtocol
|
|
|
|
import org.session.libsession.utilities.ConfigFactoryProtocol
|
|
|
|
import org.session.libsession.utilities.ConfigFactoryUpdateListener
|
|
|
|
import org.session.libsession.utilities.ConfigFactoryUpdateListener
|
|
|
|
import org.session.libsession.utilities.TextSecurePreferences
|
|
|
|
import org.session.libsession.utilities.TextSecurePreferences
|
|
|
@ -72,7 +71,6 @@ class ConfigFactory(
|
|
|
|
|
|
|
|
|
|
|
|
override val user: UserProfile?
|
|
|
|
override val user: UserProfile?
|
|
|
|
get() = synchronizedWithLog(userLock) {
|
|
|
|
get() = synchronizedWithLog(userLock) {
|
|
|
|
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
|
|
|
|
|
|
|
if (_userConfig == null) {
|
|
|
|
if (_userConfig == null) {
|
|
|
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
|
|
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
|
|
|
val userDump = configDatabase.retrieveConfigAndHashes(
|
|
|
|
val userDump = configDatabase.retrieveConfigAndHashes(
|
|
|
@ -92,7 +90,6 @@ class ConfigFactory(
|
|
|
|
|
|
|
|
|
|
|
|
override val contacts: Contacts?
|
|
|
|
override val contacts: Contacts?
|
|
|
|
get() = synchronizedWithLog(contactsLock) {
|
|
|
|
get() = synchronizedWithLog(contactsLock) {
|
|
|
|
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
|
|
|
|
|
|
|
if (_contacts == null) {
|
|
|
|
if (_contacts == null) {
|
|
|
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
|
|
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
|
|
|
val contactsDump = configDatabase.retrieveConfigAndHashes(
|
|
|
|
val contactsDump = configDatabase.retrieveConfigAndHashes(
|
|
|
@ -112,7 +109,6 @@ class ConfigFactory(
|
|
|
|
|
|
|
|
|
|
|
|
override val convoVolatile: ConversationVolatileConfig?
|
|
|
|
override val convoVolatile: ConversationVolatileConfig?
|
|
|
|
get() = synchronizedWithLog(convoVolatileLock) {
|
|
|
|
get() = synchronizedWithLog(convoVolatileLock) {
|
|
|
|
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
|
|
|
|
|
|
|
if (_convoVolatileConfig == null) {
|
|
|
|
if (_convoVolatileConfig == null) {
|
|
|
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
|
|
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
|
|
|
val convoDump = configDatabase.retrieveConfigAndHashes(
|
|
|
|
val convoDump = configDatabase.retrieveConfigAndHashes(
|
|
|
@ -133,7 +129,6 @@ class ConfigFactory(
|
|
|
|
|
|
|
|
|
|
|
|
override val userGroups: UserGroupsConfig?
|
|
|
|
override val userGroups: UserGroupsConfig?
|
|
|
|
get() = synchronizedWithLog(userGroupsLock) {
|
|
|
|
get() = synchronizedWithLog(userGroupsLock) {
|
|
|
|
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
|
|
|
|
|
|
|
if (_userGroups == null) {
|
|
|
|
if (_userGroups == null) {
|
|
|
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
|
|
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
|
|
|
val userGroupsDump = configDatabase.retrieveConfigAndHashes(
|
|
|
|
val userGroupsDump = configDatabase.retrieveConfigAndHashes(
|
|
|
@ -207,8 +202,6 @@ class ConfigFactory(
|
|
|
|
openGroupId: String?,
|
|
|
|
openGroupId: String?,
|
|
|
|
visibleOnly: Boolean
|
|
|
|
visibleOnly: Boolean
|
|
|
|
): Boolean {
|
|
|
|
): Boolean {
|
|
|
|
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val (_, userPublicKey) = maybeGetUserInfo() ?: return true
|
|
|
|
val (_, userPublicKey) = maybeGetUserInfo() ?: return true
|
|
|
|
|
|
|
|
|
|
|
|
if (openGroupId != null) {
|
|
|
|
if (openGroupId != null) {
|
|
|
@ -241,8 +234,6 @@ class ConfigFactory(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun canPerformChange(variant: String, publicKey: String, changeTimestampMs: Long): Boolean {
|
|
|
|
override fun canPerformChange(variant: String, publicKey: String, changeTimestampMs: Long): Boolean {
|
|
|
|
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val lastUpdateTimestampMs = configDatabase.retrieveConfigLastUpdateTimestamp(variant, publicKey)
|
|
|
|
val lastUpdateTimestampMs = configDatabase.retrieveConfigLastUpdateTimestamp(variant, publicKey)
|
|
|
|
|
|
|
|
|
|
|
|
// Ensure the change occurred after the last config message was handled (minus the buffer period)
|
|
|
|
// Ensure the change occurred after the last config message was handled (minus the buffer period)
|
|
|
|