diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/Errors.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/Errors.kt index 0704d2a0..bb6ab8c4 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/Errors.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/Errors.kt @@ -104,6 +104,7 @@ const val ERROR_LIBRUS_MESSAGES_OTHER = 178 const val ERROR_LOGIN_LIBRUS_MESSAGES_INVALID_LOGIN = 179 const val ERROR_LOGIN_LIBRUS_PORTAL_INVALID_LOGIN = 180 const val ERROR_LIBRUS_API_MAINTENANCE = 181 +const val ERROR_LIBRUS_PORTAL_MAINTENANCE = 182 const val ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN = 201 const val ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD = 202 diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusSynergia.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusSynergia.kt index b112fa72..11bb0c58 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusSynergia.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/LibrusSynergia.kt @@ -29,15 +29,6 @@ open class LibrusSynergia(open val data: DataLibrus) { val callback = object : TextCallbackHandler() { override fun onSuccess(text: String?, response: Response?) { - val location = response?.headers()?.get("Location") - if (location?.endsWith("przerwa_techniczna") == true) { - // double checking for maintenance? - data.error(ApiError(TAG, ERROR_LIBRUS_SYNERGIA_MAINTENANCE) - .withApiResponse(text) - .withResponse(response)) - return - } - if (text.isNullOrEmpty()) { data.error(ApiError(TAG, ERROR_RESPONSE_EMPTY) .withResponse(response)) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/login/LibrusLoginPortal.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/login/LibrusLoginPortal.kt index 19ffef22..b845ef0e 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/login/LibrusLoginPortal.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/login/LibrusLoginPortal.kt @@ -99,6 +99,14 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) { .post() .callback(object : JsonCallbackHandler() { override fun onSuccess(json: JsonObject?, response: Response) { + val location = response.headers()?.get("Location") + if (location == "http://localhost/bar?command=close") { + data.error(ApiError(TAG, ERROR_LIBRUS_PORTAL_MAINTENANCE) + .withApiResponse(json) + .withResponse(response)) + return + } + if (json == null) { if (response.parserErrorBody?.contains("wciąż nieaktywne") == true) { data.error(ApiError(TAG, ERROR_LOGIN_LIBRUS_PORTAL_NOT_ACTIVATED)