mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 10:54:36 -06:00
[API/Vulcan] Fix getting MessageBoxes and changing message read status.
This commit is contained in:
parent
cdc0c9d458
commit
7711413b30
@ -26,16 +26,24 @@ class VulcanHebeMessageBoxes(
|
||||
VULCAN_HEBE_ENDPOINT_MESSAGEBOX,
|
||||
lastSync = lastSync
|
||||
) { list, _ ->
|
||||
var found = false
|
||||
for (messageBox in list) {
|
||||
val name = messageBox.getString("Name") ?: continue
|
||||
val studentName = profile?.studentNameLong ?: continue
|
||||
if (!name.startsWith(studentName))
|
||||
if (!name.contains(studentName))
|
||||
continue
|
||||
|
||||
data.messageBoxKey = messageBox.getString("GlobalKey")
|
||||
data.messageBoxName = name
|
||||
found = true
|
||||
break
|
||||
}
|
||||
if (!found && list.isNotEmpty()) {
|
||||
list.firstOrNull()?.let { messageBox ->
|
||||
data.messageBoxKey = messageBox.getString("GlobalKey")
|
||||
data.messageBoxName = messageBox.getString("Name")
|
||||
}
|
||||
}
|
||||
data.setSyncNext(ENDPOINT_VULCAN_HEBE_MESSAGE_BOXES, 7 * DAY)
|
||||
onSuccess(ENDPOINT_VULCAN_HEBE_MESSAGE_BOXES)
|
||||
}
|
||||
|
@ -98,9 +98,6 @@ class VulcanHebeMessages(
|
||||
val receivers = message.getJsonArray("Receiver")
|
||||
?.asJsonObjectList()
|
||||
?: return@forEach
|
||||
val receiverReadDate =
|
||||
if (receivers.size == 1) readDate
|
||||
else -1
|
||||
|
||||
for (receiver in receivers) {
|
||||
val recipientId = if (messageType == TYPE_SENT)
|
||||
@ -108,6 +105,8 @@ class VulcanHebeMessages(
|
||||
else
|
||||
-1
|
||||
|
||||
val receiverReadDate = receiver.getLong("HasRead", -1)
|
||||
|
||||
val messageRecipientObject = MessageRecipient(
|
||||
profileId,
|
||||
recipientId,
|
||||
|
@ -24,7 +24,7 @@ class VulcanHebeMessagesChangeStatus(
|
||||
}
|
||||
|
||||
init { let {
|
||||
val messageKey = messageObject.body?.let { data.parseMessageMeta(it) }?.get("globalKey") ?: run {
|
||||
val messageKey = messageObject.body?.let { data.parseMessageMeta(it) }?.get("uuid") ?: run {
|
||||
EventBus.getDefault().postSticky(MessageGetEvent(messageObject))
|
||||
onSuccess()
|
||||
return@let
|
||||
|
Loading…
Reference in New Issue
Block a user