From 5558b737716e99c001852cab49452dea8db9af4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Fri, 17 May 2024 19:41:45 +0200 Subject: [PATCH] Fix eduone student registration --- build.gradle | 2 +- .../scrapper/repository/RegisterRepository.kt | 31 ++----------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index 12507aa4..01d9c216 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ ext { moshi = "1.13.0" } -version = "2.6.7" +version = "2.6.8-SNAPSHOT" group = "io.github.wulkanowy" nexusPublishing { diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/RegisterRepository.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/RegisterRepository.kt index e3c306d1..d7006bc3 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/RegisterRepository.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/RegisterRepository.kt @@ -184,9 +184,8 @@ internal class RegisterRepository( val registerStudents = runCatching { when { isEduOne -> { - val (baseStudentPlus, homepage) = loginResult.getOrThrow() + val (_, homepage) = loginResult.getOrThrow() getEduOneDiaries( - baseStudentPlus = baseStudentPlus.toString(), homepage = homepage, ) } @@ -347,9 +346,9 @@ internal class RegisterRepository( return userCache?.isParent } - private suspend fun getEduOneDiaries(baseStudentPlus: String, homepage: Document): List { + private suspend fun getEduOneDiaries(homepage: Document): List { val moduleHeaders = getModuleHeadersFromDocument(homepage) - + val baseStudentPlus = url.generate(UrlGenerator.Site.STUDENT_PLUS) val contextUrl = (baseStudentPlus + "api/Context").toHttpUrl() val contextVToken = contextUrl.getMatchedVToken(StudentPlusModuleHost, moduleHeaders) val mappedContextUrl = contextUrl.mapModuleUrl(StudentPlusModuleHost, moduleHeaders.appVersion) @@ -378,28 +377,4 @@ internal class RegisterRepository( contextStudent.mapToRegisterStudent(semesters) } } - - private suspend fun loginModule(site: UrlGenerator.Site): Pair { - loginHelper.loginModule(site) - - val baseStudentPlus = url.generate(site) - val studentPageUrl = baseStudentPlus + "LoginEndpoint.aspx" - val start = student.getStart(studentPageUrl) - - val homepage = if ("Working" in Jsoup.parse(start).title()) { - val cert = certificateAdapter.fromHtml(start) - student.sendModuleCertificate( - referer = url.createReferer(site), - url = cert.action, - certificate = mapOf( - "wa" to cert.wa, - "wresult" to cert.wresult, - "wctx" to cert.wctx, - ), - ) - } else { - start - } - return baseStudentPlus to homepage - } }