forked from github/szkolny
[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_MESSAGES_NOT_FOUND = 186
|
||||
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_OLD_PASSWORD = 202
|
||||
|
@ -34,15 +34,22 @@ class LibrusSandboxDownloadAttachment(override val data: DataLibrus,
|
||||
init {
|
||||
val keyMatcher = Regexes.LIBRUS_ATTACHMENT_KEY.find(downloadLink)
|
||||
|
||||
if (keyMatcher != null) {
|
||||
getAttachmentCheckKeyTries = 0
|
||||
|
||||
val attachmentKey = keyMatcher[1]
|
||||
getAttachmentCheckKey(attachmentKey) {
|
||||
downloadAttachment("${LIBRUS_SANDBOX_URL}CSDownload&singleUseKey=$attachmentKey", method = POST)
|
||||
when {
|
||||
downloadLink.contains("CSDownloadFailed") -> {
|
||||
data.error(ApiError(TAG, ERROR_LIBRUS_MESSAGES_ATTACHMENT_NOT_FOUND))
|
||||
onSuccess()
|
||||
}
|
||||
keyMatcher != null -> {
|
||||
getAttachmentCheckKeyTries = 0
|
||||
|
||||
val attachmentKey = keyMatcher[1]
|
||||
getAttachmentCheckKey(attachmentKey) {
|
||||
downloadAttachment("${LIBRUS_SANDBOX_URL}CSDownload&singleUseKey=$attachmentKey", method = POST)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
downloadAttachment("$downloadLink/get", method = GET)
|
||||
}
|
||||
} else {
|
||||
downloadAttachment("$downloadLink/get", method = GET)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,7 @@
|
||||
<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_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_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_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_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_202_reason">Podano stare hasło</string>
|
||||
|
Loading…
Reference in New Issue
Block a user