code review

This commit is contained in:
Valere 2021-12-17 16:43:52 +01:00
parent aa89e721aa
commit de08afdfad
5 changed files with 15 additions and 17 deletions

View File

@ -22,12 +22,11 @@ import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.internal.crypto.actions.MessageEncrypter import org.matrix.android.sdk.internal.crypto.actions.MessageEncrypter
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
import org.matrix.android.sdk.internal.crypto.tasks.DefaultSendToDeviceTask
import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask
import javax.inject.Inject import javax.inject.Inject
internal class DefaultToDeviceService @Inject constructor( internal class DefaultToDeviceService @Inject constructor(
private val sendToDeviceTask: DefaultSendToDeviceTask, private val sendToDeviceTask: SendToDeviceTask,
private val messageEncrypter: MessageEncrypter, private val messageEncrypter: MessageEncrypter,
private val cryptoStore: IMXCryptoStore private val cryptoStore: IMXCryptoStore
) : ToDeviceService { ) : ToDeviceService {

View File

@ -376,6 +376,12 @@ internal abstract class SessionModule {
@Binds @Binds
abstract fun bindOpenIdTokenService(service: DefaultOpenIdService): OpenIdService abstract fun bindOpenIdTokenService(service: DefaultOpenIdService): OpenIdService
@Binds
abstract fun bindToDeviceService(service: DefaultToDeviceService): ToDeviceService
@Binds
abstract fun bindEventStreamService(service: DefaultEventStreamService): EventStreamService
@Binds @Binds
abstract fun bindTypingUsersTracker(tracker: DefaultTypingUsersTracker): TypingUsersTracker abstract fun bindTypingUsersTracker(tracker: DefaultTypingUsersTracker): TypingUsersTracker
@ -384,10 +390,4 @@ internal abstract class SessionModule {
@Binds @Binds
abstract fun bindEventSenderProcessor(processor: EventSenderProcessorCoroutine): EventSenderProcessor abstract fun bindEventSenderProcessor(processor: EventSenderProcessorCoroutine): EventSenderProcessor
@Binds
abstract fun bindToDeviceService(deviceService: DefaultToDeviceService): ToDeviceService
@Binds
abstract fun bindEventStreamService(deviceService: DefaultEventStreamService): EventStreamService
} }

View File

@ -35,17 +35,15 @@ internal class StreamEventsManager @Inject constructor() {
private val listeners = mutableListOf<LiveEventListener>() private val listeners = mutableListOf<LiveEventListener>()
fun addLiveEventListener(listener: LiveEventListener) { fun addLiveEventListener(listener: LiveEventListener) {
Timber.v("## VALR: addLiveEventListener")
listeners.add(listener) listeners.add(listener)
} }
fun removeLiveEventListener(listener: LiveEventListener) { fun removeLiveEventListener(listener: LiveEventListener) {
Timber.v("## VALR: removeLiveEventListener")
listeners.remove(listener) listeners.remove(listener)
} }
fun dispatchLiveEventReceived(event: Event, roomId: String, initialSync: Boolean) { fun dispatchLiveEventReceived(event: Event, roomId: String, initialSync: Boolean) {
Timber.v("## VALR: dispatchLiveEventReceived ${event.eventId}") Timber.v("## dispatchLiveEventReceived ${event.eventId}")
coroutineScope.launch { coroutineScope.launch {
if (!initialSync) { if (!initialSync) {
listeners.forEach { listeners.forEach {
@ -58,7 +56,7 @@ internal class StreamEventsManager @Inject constructor() {
} }
fun dispatchPaginatedEventReceived(event: Event, roomId: String) { fun dispatchPaginatedEventReceived(event: Event, roomId: String) {
Timber.v("## VALR: dispatchPaginatedEventReceived ${event.eventId}") Timber.v("## dispatchPaginatedEventReceived ${event.eventId}")
coroutineScope.launch { coroutineScope.launch {
listeners.forEach { listeners.forEach {
tryOrNull { tryOrNull {
@ -69,7 +67,7 @@ internal class StreamEventsManager @Inject constructor() {
} }
fun dispatchLiveEventDecrypted(event: Event, result: MXEventDecryptionResult) { fun dispatchLiveEventDecrypted(event: Event, result: MXEventDecryptionResult) {
Timber.v("## VALR: dispatchLiveEventDecrypted ${event.eventId}") Timber.v("## dispatchLiveEventDecrypted ${event.eventId}")
coroutineScope.launch { coroutineScope.launch {
listeners.forEach { listeners.forEach {
tryOrNull { tryOrNull {
@ -80,7 +78,7 @@ internal class StreamEventsManager @Inject constructor() {
} }
fun dispatchLiveEventDecryptionFailed(event: Event, error: Throwable) { fun dispatchLiveEventDecryptionFailed(event: Event, error: Throwable) {
Timber.v("## VALR: dispatchLiveEventDecryptionFailed ${event.eventId}") Timber.v("## dispatchLiveEventDecryptionFailed ${event.eventId}")
coroutineScope.launch { coroutineScope.launch {
listeners.forEach { listeners.forEach {
tryOrNull { tryOrNull {
@ -91,7 +89,7 @@ internal class StreamEventsManager @Inject constructor() {
} }
fun dispatchOnLiveToDevice(event: Event) { fun dispatchOnLiveToDevice(event: Event) {
Timber.v("## VALR: dispatchOnLiveToDevice ${event.eventId}") Timber.v("## dispatchOnLiveToDevice ${event.eventId}")
coroutineScope.launch { coroutineScope.launch {
listeners.forEach { listeners.forEach {
tryOrNull { tryOrNull {

View File

@ -23,6 +23,7 @@ import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
import org.matrix.android.sdk.api.session.room.send.SendState import org.matrix.android.sdk.api.session.room.send.SendState
import org.matrix.android.sdk.internal.database.helper.addIfNecessary
import org.matrix.android.sdk.internal.database.helper.addStateEvent import org.matrix.android.sdk.internal.database.helper.addStateEvent
import org.matrix.android.sdk.internal.database.helper.addTimelineEvent import org.matrix.android.sdk.internal.database.helper.addTimelineEvent
import org.matrix.android.sdk.internal.database.mapper.toEntity import org.matrix.android.sdk.internal.database.mapper.toEntity
@ -36,6 +37,7 @@ import org.matrix.android.sdk.internal.database.query.find
import org.matrix.android.sdk.internal.database.query.where import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.session.StreamEventsManager import org.matrix.android.sdk.internal.session.StreamEventsManager
import org.matrix.android.sdk.internal.util.awaitTransaction
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject

View File

@ -170,7 +170,6 @@ class AutoRageShaker @Inject constructor(
} }
override fun onUploadSucceed(reportUrl: String?) { override fun onUploadSucceed(reportUrl: String?) {
Timber.w("## VALR Report URL is $reportUrl")
// we need to send the toDevice message to the sender // we need to send the toDevice message to the sender
coroutineScope.launch { coroutineScope.launch {
@ -190,7 +189,7 @@ class AutoRageShaker @Inject constructor(
).toContent() ).toContent()
) )
} catch (failure: Throwable) { } catch (failure: Throwable) {
Timber.w("## VALR : failed to send auto-uisi to device") Timber.w("failed to send auto-uisi to device")
} }
} }
} }