mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 10:35:19 +00:00
ignore session request before restoration & Automatically rebuild session after restoration
This commit is contained in:
parent
cb5e82ac84
commit
f18d5a3b82
@ -58,7 +58,8 @@ object SessionManagementProtocol {
|
|||||||
val apiDB = DatabaseFactory.getLokiAPIDatabase(context)
|
val apiDB = DatabaseFactory.getLokiAPIDatabase(context)
|
||||||
val sentTimestamp = apiDB.getSessionRequestSentTimestamp(publicKey) ?: 0
|
val sentTimestamp = apiDB.getSessionRequestSentTimestamp(publicKey) ?: 0
|
||||||
val processedTimestamp = apiDB.getSessionRequestProcessedTimestamp(publicKey) ?: 0
|
val processedTimestamp = apiDB.getSessionRequestProcessedTimestamp(publicKey) ?: 0
|
||||||
return timestamp > sentTimestamp && timestamp > processedTimestamp
|
val restorationTimestamp = TextSecurePreferences.getRestorationTime(context)
|
||||||
|
return timestamp > sentTimestamp && timestamp > processedTimestamp && timestamp > restorationTimestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ -95,10 +96,13 @@ object SessionManagementProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun triggerSessionRestorationUI(context: Context, publicKey: String) {
|
fun triggerSessionRestorationUI(context: Context, publicKey: String, errorTimestamp: Long) {
|
||||||
val masterDevicePublicKey = MultiDeviceProtocol.shared.getMasterDevice(publicKey) ?: publicKey
|
val masterDevicePublicKey = MultiDeviceProtocol.shared.getMasterDevice(publicKey) ?: publicKey
|
||||||
val masterDeviceAsRecipient = recipient(context, masterDevicePublicKey)
|
val masterDeviceAsRecipient = recipient(context, masterDevicePublicKey)
|
||||||
if (masterDeviceAsRecipient.isGroupRecipient) { return }
|
if (masterDeviceAsRecipient.isGroupRecipient) { return }
|
||||||
|
if (TextSecurePreferences.getRestorationTime(context) > errorTimestamp) {
|
||||||
|
return ApplicationContext.getInstance(context).sendSessionRequestIfNeeded(publicKey)
|
||||||
|
}
|
||||||
val threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(masterDeviceAsRecipient)
|
val threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(masterDeviceAsRecipient)
|
||||||
DatabaseFactory.getLokiThreadDatabase(context).addSessionRestoreDevice(threadID, publicKey)
|
DatabaseFactory.getLokiThreadDatabase(context).addSessionRestoreDevice(threadID, publicKey)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user