mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-31 13:48:20 +01:00
[API/Edudziennik] Fix downloading timetable out of the school year.
This commit is contained in:
parent
6c81a506e9
commit
39ff47e866
@ -163,6 +163,7 @@ const val ERROR_LOGIN_EDUDZIENNIK_WEB_OTHER = 510
|
||||
const val ERROR_LOGIN_EDUDZIENNIK_WEB_NO_SESSION_ID = 511
|
||||
const val ERROR_EDUDZIENNIK_WEB_TIMETABLE_NOT_PUBLIC = 520
|
||||
const val ERROR_EDUDZIENNIK_WEB_LIMITED_ACCESS = 521
|
||||
const val ERROR_EDUDZIENNIK_WEB_SESSION_EXPIRED = 522
|
||||
const val ERROR_EDUDZIENNIK_WEB_TEAM_MISSING = 530
|
||||
|
||||
const val ERROR_TEMPLATE_WEB_OTHER = 801
|
||||
|
@ -6,16 +6,13 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik
|
||||
|
||||
import com.google.gson.JsonObject
|
||||
import pl.szczodrzynski.edziennik.App
|
||||
import pl.szczodrzynski.edziennik.data.api.ERROR_EDUDZIENNIK_WEB_TIMETABLE_NOT_PUBLIC
|
||||
import pl.szczodrzynski.edziennik.data.api.ERROR_LOGIN_EDUDZIENNIK_WEB_NO_SESSION_ID
|
||||
import pl.szczodrzynski.edziennik.data.api.edudziennikLoginMethods
|
||||
import pl.szczodrzynski.edziennik.data.api.*
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.data.EdudziennikData
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.firstlogin.EdudziennikFirstLogin
|
||||
import pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.login.EdudziennikLogin
|
||||
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikCallback
|
||||
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikInterface
|
||||
import pl.szczodrzynski.edziennik.data.api.models.ApiError
|
||||
import pl.szczodrzynski.edziennik.data.api.prepare
|
||||
import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore
|
||||
import pl.szczodrzynski.edziennik.data.db.modules.messages.Message
|
||||
import pl.szczodrzynski.edziennik.data.db.modules.messages.MessageFull
|
||||
@ -131,6 +128,9 @@ class Edudziennik(val app: App, val profile: Profile?, val loginStore: LoginStor
|
||||
}
|
||||
internalErrorList.add(apiError.errorCode)
|
||||
when (apiError.errorCode) {
|
||||
ERROR_EDUDZIENNIK_WEB_SESSION_EXPIRED -> {
|
||||
login()
|
||||
}
|
||||
ERROR_LOGIN_EDUDZIENNIK_WEB_NO_SESSION_ID -> {
|
||||
login()
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ open class EdudziennikWeb(open val data: DataEdudziennik) {
|
||||
override fun onFailure(response: Response?, throwable: Throwable?) {
|
||||
val error = when (response?.code()) {
|
||||
402 -> ERROR_EDUDZIENNIK_WEB_LIMITED_ACCESS
|
||||
403 -> ERROR_EDUDZIENNIK_WEB_SESSION_EXPIRED
|
||||
else -> ERROR_REQUEST_FAILURE
|
||||
}
|
||||
data.error(ApiError(tag, error)
|
||||
|
@ -57,12 +57,16 @@ class EdudziennikWebTimetable(override val data: DataEdudziennik,
|
||||
val table = doc.select("#Schedule tbody").first()
|
||||
|
||||
if (table.text().trim() == "Brak planu lekcji.") {
|
||||
val today = Date.getToday()
|
||||
val schoolYearStart = if (today.month >= 9) today.year else today.year - 1
|
||||
|
||||
if (weekStart >= Date(schoolYearStart, 9, 1)) {
|
||||
data.error(ApiError(TAG, ERROR_EDUDZIENNIK_WEB_TIMETABLE_NOT_PUBLIC)
|
||||
.withApiResponse(text))
|
||||
onSuccess()
|
||||
return@webGet
|
||||
}
|
||||
|
||||
} else {
|
||||
table.children().forEach { row ->
|
||||
val rowElements = row.children()
|
||||
|
||||
@ -136,6 +140,7 @@ class EdudziennikWebTimetable(override val data: DataEdudziennik,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (day in dataDays) {
|
||||
val lessonDate = Date.fromValue(day)
|
||||
|
@ -19,6 +19,7 @@
|
||||
<string name="error_110" translatable="false">ERROR_INVALID_LOGIN_MODE</string>
|
||||
<string name="error_111" translatable="false">ERROR_LOGIN_METHOD_NOT_SATISFIED</string>
|
||||
<string name="error_112" translatable="false">ERROR_NOT_IMPLEMENTED</string>
|
||||
<string name="error_113" translatable="false">ERROR_FILE_DOWNLOAD</string>
|
||||
|
||||
<string name="error_115" translatable="false">ERROR_NO_STUDENTS_IN_ACCOUNT</string>
|
||||
|
||||
@ -132,6 +133,7 @@
|
||||
<string name="error_511" translatable="false">ERROR_LOGIN_EDUDZIENNIK_WEB_NO_SESSION_ID</string>
|
||||
<string name="error_520" translatable="false">ERROR_EDUDZIENNIK_WEB_TIMETABLE_NOT_PUBLIC</string>
|
||||
<string name="error_521" translatable="false">ERROR_EDUDZIENNIK_WEB_LIMITED_ACCESS</string>
|
||||
<string name="error_522" translatable="false">ERROR_EDUDZIENNIK_WEB_SESSION_EXPIRED</string>
|
||||
<string name="error_530" translatable="false">ERROR_EDUDZIENNIK_WEB_TEAM_MISSING</string>
|
||||
|
||||
<string name="error_801" translatable="false">ERROR_TEMPLATE_WEB_OTHER</string>
|
||||
@ -168,6 +170,7 @@
|
||||
<string name="error_110_reason">Nieprawidłowy sposób logowania</string>
|
||||
<string name="error_111_reason">Nie można wywołać metody logowania</string>
|
||||
<string name="error_112_reason">Nie zaimplementowano</string>
|
||||
<string name="error_113_reason">Wystąpił błąd podczas pobierania pliku</string>
|
||||
|
||||
<string name="error_115_reason">Brak uczniów przypisanych do konta</string>
|
||||
|
||||
@ -281,6 +284,7 @@
|
||||
<string name="error_511_reason">Brak ID sesji</string>
|
||||
<string name="error_520_reason">Plan lekcji niedostępny</string>
|
||||
<string name="error_521_reason">Ograniczony dostęp do dziennika</string>
|
||||
<string name="error_522_reason">Sesja wygasła</string>
|
||||
<string name="error_530_reason">Nie można pobrać informacji o klasie i szkole</string>
|
||||
|
||||
<string name="error_801_reason">ERROR_TEMPLATE_WEB_OTHER</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user