Add vheaders to uonetplus-uczen during register

This commit is contained in:
Mikołaj Pich 2024-05-29 16:56:20 +02:00
parent 1f6a0471e5
commit c812f272eb
No known key found for this signature in database
2 changed files with 11 additions and 8 deletions

View file

@ -245,15 +245,14 @@ internal class RegisterRepository(
}
private suspend fun getStudentDiaries(startPage: String): List<Diary> {
val appVersion = getScriptParam("version", startPage).ifBlank {
getScriptParam("appVersion", startPage)
}
val diaryUrl = (url.generate(UrlGenerator.Site.STUDENT) + "UczenDziennik.mvc/Get")
.toHttpUrl()
.mapModuleUrl(StudentModuleHost, appVersion)
val moduleHeaders = getModuleHeadersFromDocument(Jsoup.parse(startPage))
val baseStudent = url.generate(UrlGenerator.Site.STUDENT)
val diaryUrl = (baseStudent + "UczenDziennik.mvc/Get").toHttpUrl()
val vHeaders = getVHeaders(StudentModuleHost, diaryUrl, moduleHeaders)
val mappedDiaryUrl = diaryUrl.mapModuleUrl(StudentModuleHost, moduleHeaders.appVersion)
return student
.getSchoolInfo(url = diaryUrl.toString())
.getSchoolInfo(vHeaders = vHeaders, url = mappedDiaryUrl.toString())
.handleErrors()
.data.orEmpty()
}

View file

@ -42,6 +42,7 @@ import retrofit2.http.FieldMap
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.HeaderMap
import retrofit2.http.POST
import retrofit2.http.Url
@ -81,7 +82,10 @@ internal interface StudentService {
): ApiResponse<AuthorizePermissionResponse>
@POST
suspend fun getSchoolInfo(@Url url: String, @Body body: Any = Any()): ApiResponse<List<Diary>>
suspend fun getSchoolInfo(
@HeaderMap vHeaders: Map<String, String>,
@Url url: String, @Body body: Any = Any(),
): ApiResponse<List<Diary>>
@POST("UczenDziennik.mvc/Get")
suspend fun getDiaries(