From 8a30c6c7ce872946e9e12751175cf854c7737663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Thu, 26 Sep 2019 18:48:45 +0200 Subject: [PATCH] [API/Vulcan] Fix messages mark-as-read. Fix sent messages & attendances sync. --- .../pl/szczodrzynski/edziennik/api/Vulcan.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java index 7a3deede..f3a84477 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/Vulcan.java @@ -113,6 +113,7 @@ public class Vulcan implements EdziennikInterface { private static final String ENDPOINT_ATTENDANCES = "mobile-api/Uczen.v3.Uczen/Frekwencje"; private static final String ENDPOINT_MESSAGES_RECEIVED = "mobile-api/Uczen.v3.Uczen/WiadomosciOdebrane"; private static final String ENDPOINT_MESSAGES_SENT = "mobile-api/Uczen.v3.Uczen/WiadomosciWyslane"; + private static final String ENDPOINT_MESSAGES_CHANGE_STATUS = "mobile-api/Uczen.v3.Uczen/ZmienStatusWiadomosci"; private static final String ENDPOINT_PUSH = "mobile-api/Uczen.v3.Uczen/UstawPushToken"; private static final String userAgent = "MobileUserAgent"; @@ -427,8 +428,10 @@ public class Vulcan implements EdziennikInterface { app.db.noticeDao().clearForSemester(profileId, studentSemesterNumber); app.db.noticeDao().addAll(noticeList); } - if (attendanceList.size() > 0) + if (attendanceList.size() > 0) { + app.db.attendanceDao().clearAfterDate(profileId, getCurrentSemesterStartDate()); app.db.attendanceDao().addAll(attendanceList); + } if (messageList.size() > 0) app.db.messageDao().addAllIgnore(messageList); if (messageRecipientList.size() > 0) @@ -1506,8 +1509,8 @@ public class Vulcan implements EdziennikInterface { private void getMessagesInbox() { callback.onActionStarted(R.string.sync_action_syncing_messages_inbox); JsonObject json = new JsonObject(); - json.addProperty("DataPoczatkowa", profile.getEmpty() ? getCurrentSemesterStartDate().getInUnix() : oneMonthBack.getInUnix()); - json.addProperty("DataKoncowa", Date.getToday().getInUnix()); + json.addProperty("DataPoczatkowa", true ? getCurrentSemesterStartDate().getInUnix() : oneMonthBack.getInUnix()); + json.addProperty("DataKoncowa", getCurrentSemesterEndDate().getInUnix()); json.addProperty("LoginId", studentLoginId); json.addProperty("IdUczen", studentId); apiRequest(schoolSymbol+"/"+ENDPOINT_MESSAGES_RECEIVED, json, result -> { @@ -1557,8 +1560,8 @@ public class Vulcan implements EdziennikInterface { } callback.onActionStarted(R.string.sync_action_syncing_messages_outbox); JsonObject json = new JsonObject(); - json.addProperty("DataPoczatkowa", profile.getEmpty() ? getCurrentSemesterStartDate().getInUnix() : oneMonthBack.getInUnix()); - json.addProperty("DataKoncowa", Date.getToday().getInUnix()); + json.addProperty("DataPoczatkowa", true ? getCurrentSemesterStartDate().getInUnix() : oneMonthBack.getInUnix()); + json.addProperty("DataKoncowa", getCurrentSemesterEndDate().getInUnix()); json.addProperty("LoginId", studentLoginId); json.addProperty("IdUczen", studentId); apiRequest(schoolSymbol+"/"+ENDPOINT_MESSAGES_SENT, json, result -> { @@ -1640,7 +1643,7 @@ public class Vulcan implements EdziennikInterface { json.addProperty("Status", "Widoczna"); json.addProperty("LoginId", studentLoginId); json.addProperty("IdUczen", studentId); - apiRequest(schoolSymbol+"/ZmienStatusWiadomosci", json, result -> { }); + apiRequest(schoolSymbol+"/"+ENDPOINT_MESSAGES_CHANGE_STATUS, json, result -> { }); app.db.metadataDao().setSeen(profile.getId(), message, true); if (message.type != TYPE_SENT) { app.db.messageRecipientDao().add(new MessageRecipient(profile.getId(), -1, -1, System.currentTimeMillis(), message.id));