Browse Source

Close MatrixClient after usage

test/jme/compound-poc
Benoit Marty 1 year ago committed by Benoit Marty
parent
commit
9fe42691ea
  1. 7
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/PushersManager.kt
  2. 12
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/push/PushHandler.kt

7
libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/PushersManager.kt

@ -77,10 +77,9 @@ class PushersManager @Inject constructor( @@ -77,10 +77,9 @@ class PushersManager @Inject constructor(
sessionStore.getAllSessions().toUserList().forEach { userId ->
val userDataStore = userPushStoreFactory.create(userId)
if (userDataStore.isFirebase()) {
val client = matrixAuthenticationService.restoreSession(SessionId(userId)).getOrNull()
client ?: return@forEach
registerPusher(client, firebaseToken, PushConfig.pusher_http_url)
// TODO EAx Close sessions
matrixAuthenticationService.restoreSession(SessionId(userId)).getOrNull()?.use { client ->
registerPusher(client, firebaseToken, PushConfig.pusher_http_url)
}
} else {
Timber.d("This session is not using Firebase pusher")
}

12
libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/push/PushHandler.kt

@ -141,11 +141,13 @@ class PushHandler @Inject constructor( @@ -141,11 +141,13 @@ class PushHandler @Inject constructor(
// Restore session
val session = matrixAuthenticationService.restoreSession(SessionId(userId)).getOrNull() ?: return
// TODO EAx, no need for a session?
val notificationData = session.notificationService().getNotification(
userId = userId,
roomId = pushData.roomId,
eventId = pushData.eventId,
)
val notificationData = session.use {
it.notificationService().getNotification(
userId = userId,
roomId = pushData.roomId,
eventId = pushData.eventId,
)
}
// TODO Remove
Timber.w("Notification: $notificationData")

Loading…
Cancel
Save