mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-31 05:48:19 +01:00
[API/Librus] Add handling missing attachment error.
This commit is contained in:
parent
f98b174857
commit
ea4919a25d
@ -126,6 +126,7 @@ const val ERROR_LOGIN_LIBRUS_PORTAL_CSRF_EXPIRED = 184
|
|||||||
const val ERROR_LIBRUS_API_DEVICE_REGISTERED = 185
|
const val ERROR_LIBRUS_API_DEVICE_REGISTERED = 185
|
||||||
const val ERROR_LIBRUS_MESSAGES_NOT_FOUND = 186
|
const val ERROR_LIBRUS_MESSAGES_NOT_FOUND = 186
|
||||||
const val ERROR_LOGIN_LIBRUS_API_INVALID_REQUEST = 187
|
const val ERROR_LOGIN_LIBRUS_API_INVALID_REQUEST = 187
|
||||||
|
const val ERROR_LIBRUS_MESSAGES_ATTACHMENT_NOT_FOUND = 188
|
||||||
|
|
||||||
const val ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN = 201
|
const val ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN = 201
|
||||||
const val ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD = 202
|
const val ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD = 202
|
||||||
|
@ -34,17 +34,24 @@ class LibrusSandboxDownloadAttachment(override val data: DataLibrus,
|
|||||||
init {
|
init {
|
||||||
val keyMatcher = Regexes.LIBRUS_ATTACHMENT_KEY.find(downloadLink)
|
val keyMatcher = Regexes.LIBRUS_ATTACHMENT_KEY.find(downloadLink)
|
||||||
|
|
||||||
if (keyMatcher != null) {
|
when {
|
||||||
|
downloadLink.contains("CSDownloadFailed") -> {
|
||||||
|
data.error(ApiError(TAG, ERROR_LIBRUS_MESSAGES_ATTACHMENT_NOT_FOUND))
|
||||||
|
onSuccess()
|
||||||
|
}
|
||||||
|
keyMatcher != null -> {
|
||||||
getAttachmentCheckKeyTries = 0
|
getAttachmentCheckKeyTries = 0
|
||||||
|
|
||||||
val attachmentKey = keyMatcher[1]
|
val attachmentKey = keyMatcher[1]
|
||||||
getAttachmentCheckKey(attachmentKey) {
|
getAttachmentCheckKey(attachmentKey) {
|
||||||
downloadAttachment("${LIBRUS_SANDBOX_URL}CSDownload&singleUseKey=$attachmentKey", method = POST)
|
downloadAttachment("${LIBRUS_SANDBOX_URL}CSDownload&singleUseKey=$attachmentKey", method = POST)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else -> {
|
||||||
downloadAttachment("$downloadLink/get", method = GET)
|
downloadAttachment("$downloadLink/get", method = GET)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getAttachmentCheckKey(attachmentKey: String, callback: () -> Unit) {
|
private fun getAttachmentCheckKey(attachmentKey: String, callback: () -> Unit) {
|
||||||
sandboxGet(LibrusMessagesGetAttachment.TAG, "CSCheckKey",
|
sandboxGet(LibrusMessagesGetAttachment.TAG, "CSCheckKey",
|
||||||
|
@ -98,6 +98,7 @@
|
|||||||
<string name="error_185" translatable="false">ERROR_LIBRUS_API_DEVICE_REGISTERED</string>
|
<string name="error_185" translatable="false">ERROR_LIBRUS_API_DEVICE_REGISTERED</string>
|
||||||
<string name="error_186" translatable="false">ERROR_LIBRUS_MESSAGES_NOT_FOUND</string>
|
<string name="error_186" translatable="false">ERROR_LIBRUS_MESSAGES_NOT_FOUND</string>
|
||||||
<string name="error_187" translatable="false">ERROR_LOGIN_LIBRUS_API_INVALID_REQUEST</string>
|
<string name="error_187" translatable="false">ERROR_LOGIN_LIBRUS_API_INVALID_REQUEST</string>
|
||||||
|
<string name="error_188" translatable="false">ERROR_LIBRUS_MESSAGES_ATTACHMENT_NOT_FOUND</string>
|
||||||
|
|
||||||
<string name="error_201" translatable="false">ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN</string>
|
<string name="error_201" translatable="false">ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN</string>
|
||||||
<string name="error_202" translatable="false">ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD</string>
|
<string name="error_202" translatable="false">ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD</string>
|
||||||
@ -273,6 +274,7 @@
|
|||||||
<string name="error_185_reason">Urządzenie jest już zarejestrowane</string>
|
<string name="error_185_reason">Urządzenie jest już zarejestrowane</string>
|
||||||
<string name="error_186_reason">Nie znaleziono wiadomości. Mogła zostać usunięta.</string>
|
<string name="error_186_reason">Nie znaleziono wiadomości. Mogła zostać usunięta.</string>
|
||||||
<string name="error_187_reason">Nieprawidłowe dane dostępu. Sprawdź poprawność wprowadzonych danych.</string>
|
<string name="error_187_reason">Nieprawidłowe dane dostępu. Sprawdź poprawność wprowadzonych danych.</string>
|
||||||
|
<string name="error_188_reason">Nie znaleziono załącznika. Mógł zostać usunięty.</string>
|
||||||
|
|
||||||
<string name="error_201_reason">Nieprawidłowy login lub hasło</string>
|
<string name="error_201_reason">Nieprawidłowy login lub hasło</string>
|
||||||
<string name="error_202_reason">Podano stare hasło</string>
|
<string name="error_202_reason">Podano stare hasło</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user