diff --git a/app/build.gradle b/app/build.gradle index a61d0a1d..4cde3c29 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,8 +23,8 @@ android { testApplicationId "io.github.tests.wulkanowy" minSdkVersion 21 targetSdkVersion 32 - versionCode 117 - versionName "1.8.2" + versionCode 118 + versionName "1.8.3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" resValue "string", "app_name", "Wulkanowy" @@ -186,7 +186,7 @@ ext { } dependencies { - implementation "io.github.wulkanowy:sdk:1.8.2" + implementation "io.github.wulkanowy:sdk:1.8.3" coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8' diff --git a/app/src/main/java/io/github/wulkanowy/data/mappers/MessageMapper.kt b/app/src/main/java/io/github/wulkanowy/data/mappers/MessageMapper.kt index 120eb183..2ede5aa1 100644 --- a/app/src/main/java/io/github/wulkanowy/data/mappers/MessageMapper.kt +++ b/app/src/main/java/io/github/wulkanowy/data/mappers/MessageMapper.kt @@ -2,6 +2,7 @@ package io.github.wulkanowy.data.mappers import io.github.wulkanowy.data.db.entities.* import io.github.wulkanowy.sdk.pojo.MailboxType +import timber.log.Timber import io.github.wulkanowy.sdk.pojo.Message as SdkMessage import io.github.wulkanowy.sdk.pojo.MessageAttachment as SdkMessageAttachment import io.github.wulkanowy.sdk.pojo.Recipient as SdkRecipient @@ -16,7 +17,10 @@ fun List.mapToEntities( mailboxKey = mailbox?.globalKey ?: allMailboxes.find { box -> box.fullName == it.mailbox }?.globalKey.let { mailboxKey -> - requireNotNull(mailboxKey) { "Can't find ${it.mailbox} in $allMailboxes" } + if (mailboxKey == null) { + Timber.e("Can't find ${it.mailbox} in $allMailboxes") + "unknown" + } else mailboxKey }, email = student.email, messageId = it.id, diff --git a/app/src/main/java/io/github/wulkanowy/domain/messages/GetMailboxByStudentUseCase.kt b/app/src/main/java/io/github/wulkanowy/domain/messages/GetMailboxByStudentUseCase.kt index a696d9b2..669514aa 100644 --- a/app/src/main/java/io/github/wulkanowy/domain/messages/GetMailboxByStudentUseCase.kt +++ b/app/src/main/java/io/github/wulkanowy/domain/messages/GetMailboxByStudentUseCase.kt @@ -17,8 +17,11 @@ class GetMailboxByStudentUseCase @Inject constructor( private fun List.filterByStudent(student: Student): Mailbox? { val normalizedStudentName = student.studentName.normalizeStudentName() - return find { + return singleOrNull { it.studentName.normalizeStudentName() == normalizedStudentName + } ?: singleOrNull { + it.studentName.normalizeStudentName() == normalizedStudentName + && it.schoolNameShort == student.schoolShortName } ?: singleOrNull { it.studentName.getFirstAndLastPart() == normalizedStudentName.getFirstAndLastPart() } ?: singleOrNull { diff --git a/app/src/main/play/release-notes/pl-PL/default.txt b/app/src/main/play/release-notes/pl-PL/default.txt index c4f4c6cf..5a47ddc7 100644 --- a/app/src/main/play/release-notes/pl-PL/default.txt +++ b/app/src/main/play/release-notes/pl-PL/default.txt @@ -1,7 +1,8 @@ -Wersja 1.8.2 +Wersja 1.8.3 - naprawiliśmy logowanie dla użytkowników systemu Resman Rzeszów - dodaliśmy wsparcie dla nowej platformy z Tomaszowa Mazowieckiego +- poprawiliśmy dopasowywanie skrzynek pocztowych do uczniów - naprawiliśmy literówkę w tytule wiadomości z szablonem usprawiedliwienia Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases diff --git a/app/src/test/java/io/github/wulkanowy/domain/GetMailboxByStudentUseCaseTest.kt b/app/src/test/java/io/github/wulkanowy/domain/GetMailboxByStudentUseCaseTest.kt index 02980026..6db16d2f 100644 --- a/app/src/test/java/io/github/wulkanowy/domain/GetMailboxByStudentUseCaseTest.kt +++ b/app/src/test/java/io/github/wulkanowy/domain/GetMailboxByStudentUseCaseTest.kt @@ -160,8 +160,29 @@ class GetMailboxByStudentUseCaseTest { assertEquals(expectedMailbox, systemUnderTest(student)) } + @Test + fun `get mailbox for student with mailboxes from two different schools`() = runTest { + val student = getStudentEntity( + userName = "Kamil Bednarek", + studentName = "Kamil Bednarek", + schoolShortName = "CKZiU", + ) + val mailbox1 = getMailboxEntity( + studentName = "Kamil Bednarek", + schoolShortName = "ZSTiO", + ) + val mailbox2 = getMailboxEntity( + studentName = "Kamil Bednarek", + schoolShortName = "CKZiU", + ) + coEvery { mailboxDao.loadAll(any()) } returns listOf(mailbox1, mailbox2) + + assertEquals(mailbox2, systemUnderTest(student)) + } + private fun getMailboxEntity( studentName: String, + schoolShortName: String = "test", ) = Mailbox( globalKey = "", fullName = "", @@ -170,13 +191,14 @@ class GetMailboxByStudentUseCaseTest { schoolId = "", symbol = "", studentName = studentName, - schoolNameShort = "", + schoolNameShort = schoolShortName, type = MailboxType.STUDENT, ) private fun getStudentEntity( studentName: String, userName: String, + schoolShortName: String = "test", ) = Student( scrapperBaseUrl = "http://fakelog.cf", email = "jan@fakelog.cf", @@ -192,7 +214,7 @@ class GetMailboxByStudentUseCaseTest { privateKey = "", registrationDate = Instant.now(), schoolName = "", - schoolShortName = "test", + schoolShortName = schoolShortName, schoolSymbol = "", studentId = 1, studentName = studentName,