From 448fd0e8846859d32daea0d86635454a1d8acf7f Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Mon, 10 Feb 2020 23:53:04 +0100 Subject: [PATCH] [API/Librus] Fix marking removed announcements as read. --- .../java/pl/szczodrzynski/edziennik/data/api/Errors.kt | 1 + .../edziennik/data/api/edziennik/librus/data/LibrusApi.kt | 1 + .../librus/data/api/LibrusApiAnnouncementMarkAsRead.kt | 8 ++++++-- app/src/main/res/values/errors.xml | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Errors.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Errors.kt index 7ca226d3..94930aed 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Errors.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Errors.kt @@ -116,6 +116,7 @@ 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_LIBRUS_API_NOTICEBOARD_PROBLEM = 183 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/data/api/edziennik/librus/data/LibrusApi.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusApi.kt index aa3db971..ed9c98d5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusApi.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/LibrusApi.kt @@ -63,6 +63,7 @@ open class LibrusApi(open val data: DataLibrus) { "NotesIsNotActive" -> ERROR_LIBRUS_API_NOTES_NOT_ACTIVE "InvalidRequest" -> ERROR_LIBRUS_API_INVALID_REQUEST_PARAMS "Nieprawidłowy węzeł." -> ERROR_LIBRUS_API_INCORRECT_ENDPOINT + "NoticeboardProblem" -> ERROR_LIBRUS_API_NOTICEBOARD_PROBLEM else -> ERROR_LIBRUS_API_OTHER }.let { errorCode -> if (errorCode !in ignoreErrors) { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiAnnouncementMarkAsRead.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiAnnouncementMarkAsRead.kt index b36721f1..de265741 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiAnnouncementMarkAsRead.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/data/api/LibrusApiAnnouncementMarkAsRead.kt @@ -6,12 +6,13 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.api import org.greenrobot.eventbus.EventBus import pl.szczodrzynski.edziennik.data.api.ERROR_LIBRUS_API_INVALID_REQUEST_PARAMS +import pl.szczodrzynski.edziennik.data.api.ERROR_LIBRUS_API_NOTICEBOARD_PROBLEM import pl.szczodrzynski.edziennik.data.api.POST import pl.szczodrzynski.edziennik.data.api.edziennik.librus.DataLibrus import pl.szczodrzynski.edziennik.data.api.edziennik.librus.data.LibrusApi import pl.szczodrzynski.edziennik.data.api.events.AnnouncementGetEvent -import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull import pl.szczodrzynski.edziennik.data.db.entity.Metadata +import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull class LibrusApiAnnouncementMarkAsRead( override val data: DataLibrus, @@ -24,7 +25,10 @@ class LibrusApiAnnouncementMarkAsRead( init { apiGet(TAG, "SchoolNotices/MarkAsRead/${announcement.idString}", method = POST, - ignoreErrors = listOf(ERROR_LIBRUS_API_INVALID_REQUEST_PARAMS)) { + ignoreErrors = listOf( + ERROR_LIBRUS_API_INVALID_REQUEST_PARAMS, + ERROR_LIBRUS_API_NOTICEBOARD_PROBLEM + )) { announcement.seen = true EventBus.getDefault().postSticky(AnnouncementGetEvent(announcement)) diff --git a/app/src/main/res/values/errors.xml b/app/src/main/res/values/errors.xml index 7aeabb87..00d6a4e3 100644 --- a/app/src/main/res/values/errors.xml +++ b/app/src/main/res/values/errors.xml @@ -90,6 +90,7 @@ ERROR_LOGIN_LIBRUS_PORTAL_INVALID_LOGIN ERROR_LIBRUS_API_MAINTENANCE ERROR_LIBRUS_PORTAL_MAINTENANCE + ERROR_LIBRUS_API_NOTICEBOARD_PROBLEM ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD @@ -256,6 +257,7 @@ Librus Portal: nieprawidłowe dane logowania Librus API: przerwa techniczna Librus Portal: przerwa techniczna + Wystąpił problem z tablicą ogłoszeń Nieprawidłowy login lub hasło Podano stare hasło