From 2121ec5739d6ce448af49c89f921dd5cd0945c76 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 18 Jul 2022 14:53:44 +0200 Subject: [PATCH] Moving use case to check if event is redacted into a dedicated package --- .../features/location/LocationSharingAndroidService.kt | 6 +++--- .../CheckIfEventIsRedactedUseCase.kt} | 4 ++-- .../CheckIfEventIsRedactedUseCaseTest.kt} | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) rename vector/src/main/java/im/vector/app/features/{location/live/CheckIfLiveLocationShareIsRedactedUseCase.kt => redaction/CheckIfEventIsRedactedUseCase.kt} (91%) rename vector/src/test/java/im/vector/app/features/{location/live/CheckIfLiveLocationShareIsRedactedUseCaseTest.kt => redaction/CheckIfEventIsRedactedUseCaseTest.kt} (81%) diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingAndroidService.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingAndroidService.kt index b3c88ccd93..bf022e0088 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingAndroidService.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingAndroidService.kt @@ -24,7 +24,7 @@ import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.services.VectorAndroidService -import im.vector.app.features.location.live.CheckIfLiveLocationShareIsRedactedUseCase +import im.vector.app.features.redaction.CheckIfEventIsRedactedUseCase import im.vector.app.features.location.live.GetLiveLocationShareSummaryUseCase import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.session.coroutineScope @@ -56,7 +56,7 @@ class LocationSharingAndroidService : VectorAndroidService(), LocationTracker.Ca @Inject lateinit var locationTracker: LocationTracker @Inject lateinit var activeSessionHolder: ActiveSessionHolder @Inject lateinit var getLiveLocationShareSummaryUseCase: GetLiveLocationShareSummaryUseCase - @Inject lateinit var checkIfLiveLocationShareIsRedactedUseCase: CheckIfLiveLocationShareIsRedactedUseCase + @Inject lateinit var checkIfEventIsRedactedUseCase: CheckIfEventIsRedactedUseCase private val binder = LocalBinder() @@ -214,7 +214,7 @@ class LocationSharingAndroidService : VectorAndroidService(), LocationTracker.Ca } private suspend fun isLiveRedacted(roomId: String, beaconEventId: String): Boolean { - return checkIfLiveLocationShareIsRedactedUseCase.execute(roomId = roomId, eventId = beaconEventId) + return checkIfEventIsRedactedUseCase.execute(roomId = roomId, eventId = beaconEventId) } private fun launchWithActiveSession(block: suspend CoroutineScope.(Session) -> Unit) = diff --git a/vector/src/main/java/im/vector/app/features/location/live/CheckIfLiveLocationShareIsRedactedUseCase.kt b/vector/src/main/java/im/vector/app/features/redaction/CheckIfEventIsRedactedUseCase.kt similarity index 91% rename from vector/src/main/java/im/vector/app/features/location/live/CheckIfLiveLocationShareIsRedactedUseCase.kt rename to vector/src/main/java/im/vector/app/features/redaction/CheckIfEventIsRedactedUseCase.kt index 123e1be7a3..ac77455d66 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/CheckIfLiveLocationShareIsRedactedUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/redaction/CheckIfEventIsRedactedUseCase.kt @@ -14,13 +14,13 @@ * limitations under the License. */ -package im.vector.app.features.location.live +package im.vector.app.features.redaction import org.matrix.android.sdk.api.session.Session import timber.log.Timber import javax.inject.Inject -class CheckIfLiveLocationShareIsRedactedUseCase @Inject constructor( +class CheckIfEventIsRedactedUseCase @Inject constructor( private val session: Session, ) { diff --git a/vector/src/test/java/im/vector/app/features/location/live/CheckIfLiveLocationShareIsRedactedUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/redaction/CheckIfEventIsRedactedUseCaseTest.kt similarity index 81% rename from vector/src/test/java/im/vector/app/features/location/live/CheckIfLiveLocationShareIsRedactedUseCaseTest.kt rename to vector/src/test/java/im/vector/app/features/redaction/CheckIfEventIsRedactedUseCaseTest.kt index 0cb6a09ad5..7dffd78516 100644 --- a/vector/src/test/java/im/vector/app/features/location/live/CheckIfLiveLocationShareIsRedactedUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/redaction/CheckIfEventIsRedactedUseCaseTest.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.app.features.location.live +package im.vector.app.features.redaction import im.vector.app.test.fakes.FakeSession import kotlinx.coroutines.test.runTest @@ -26,11 +26,11 @@ import org.matrix.android.sdk.api.session.events.model.UnsignedData private const val A_ROOM_ID = "room_id" private const val AN_EVENT_ID = "event_id" -class CheckIfLiveLocationShareIsRedactedUseCaseTest { +class CheckIfEventIsRedactedUseCaseTest { private val fakeSession = FakeSession() - private val checkIfLiveLocationShareIsRedactedUseCase = CheckIfLiveLocationShareIsRedactedUseCase( + private val checkIfEventIsRedactedUseCase = CheckIfEventIsRedactedUseCase( session = fakeSession ) @@ -42,7 +42,7 @@ class CheckIfLiveLocationShareIsRedactedUseCaseTest { fakeSession.eventService() .givenGetEventReturns(event) - val result = checkIfLiveLocationShareIsRedactedUseCase.execute(A_ROOM_ID, AN_EVENT_ID) + val result = checkIfEventIsRedactedUseCase.execute(A_ROOM_ID, AN_EVENT_ID) result shouldBeEqualTo true } @@ -53,7 +53,7 @@ class CheckIfLiveLocationShareIsRedactedUseCaseTest { fakeSession.eventService() .givenGetEventReturns(event) - val result = checkIfLiveLocationShareIsRedactedUseCase.execute(A_ROOM_ID, AN_EVENT_ID) + val result = checkIfEventIsRedactedUseCase.execute(A_ROOM_ID, AN_EVENT_ID) result shouldBeEqualTo false }