mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-04 06:05:39 +00:00
Merge pull request #1087 from 0x330a/fix/expire-old-call-messages
Prevent very old messages (15 minutes ago) being processed to prevent endless crashes in some cases
This commit is contained in:
commit
bdac7f2ea3
@ -12,6 +12,7 @@ import org.session.libsession.database.StorageProtocol
|
|||||||
import org.session.libsession.messaging.calls.CallMessageType
|
import org.session.libsession.messaging.calls.CallMessageType
|
||||||
import org.session.libsession.messaging.messages.control.CallMessage
|
import org.session.libsession.messaging.messages.control.CallMessage
|
||||||
import org.session.libsession.messaging.utilities.WebRtcUtils
|
import org.session.libsession.messaging.utilities.WebRtcUtils
|
||||||
|
import org.session.libsession.snode.SnodeAPI
|
||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.Address
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
@ -29,6 +30,10 @@ import org.webrtc.IceCandidate
|
|||||||
|
|
||||||
class CallMessageProcessor(private val context: Context, private val textSecurePreferences: TextSecurePreferences, lifecycle: Lifecycle, private val storage: StorageProtocol) {
|
class CallMessageProcessor(private val context: Context, private val textSecurePreferences: TextSecurePreferences, lifecycle: Lifecycle, private val storage: StorageProtocol) {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val VERY_EXPIRED_TIME = 15 * 60 * 1000L
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
lifecycle.coroutineScope.launch(IO) {
|
lifecycle.coroutineScope.launch(IO) {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
@ -53,6 +58,13 @@ class CallMessageProcessor(private val context: Context, private val textSecureP
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val isVeryExpired = (nextMessage.sentTimestamp?:0) + VERY_EXPIRED_TIME < SnodeAPI.nowWithOffset
|
||||||
|
if (isVeryExpired) {
|
||||||
|
Log.e("Loki", "Dropping very expired call message")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
when (nextMessage.type) {
|
when (nextMessage.type) {
|
||||||
OFFER -> incomingCall(nextMessage)
|
OFFER -> incomingCall(nextMessage)
|
||||||
ANSWER -> incomingAnswer(nextMessage)
|
ANSWER -> incomingAnswer(nextMessage)
|
||||||
|
@ -56,6 +56,10 @@ object SnodeAPI {
|
|||||||
* user's clock is incorrect.
|
* user's clock is incorrect.
|
||||||
*/
|
*/
|
||||||
internal var clockOffset = 0L
|
internal var clockOffset = 0L
|
||||||
|
|
||||||
|
val nowWithOffset
|
||||||
|
get() = System.currentTimeMillis() + clockOffset
|
||||||
|
|
||||||
internal var forkInfo by observable(database.getForkInfo()) { _, oldValue, newValue ->
|
internal var forkInfo by observable(database.getForkInfo()) { _, oldValue, newValue ->
|
||||||
if (newValue > oldValue) {
|
if (newValue > oldValue) {
|
||||||
Log.d("Loki", "Setting new fork info new: $newValue, old: $oldValue")
|
Log.d("Loki", "Setting new fork info new: $newValue, old: $oldValue")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user