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,
|
VULCAN_HEBE_ENDPOINT_MESSAGEBOX,
|
||||||
lastSync = lastSync
|
lastSync = lastSync
|
||||||
) { list, _ ->
|
) { list, _ ->
|
||||||
|
var found = false
|
||||||
for (messageBox in list) {
|
for (messageBox in list) {
|
||||||
val name = messageBox.getString("Name") ?: continue
|
val name = messageBox.getString("Name") ?: continue
|
||||||
val studentName = profile?.studentNameLong ?: continue
|
val studentName = profile?.studentNameLong ?: continue
|
||||||
if (!name.startsWith(studentName))
|
if (!name.contains(studentName))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
data.messageBoxKey = messageBox.getString("GlobalKey")
|
data.messageBoxKey = messageBox.getString("GlobalKey")
|
||||||
data.messageBoxName = name
|
data.messageBoxName = name
|
||||||
|
found = true
|
||||||
break
|
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)
|
data.setSyncNext(ENDPOINT_VULCAN_HEBE_MESSAGE_BOXES, 7 * DAY)
|
||||||
onSuccess(ENDPOINT_VULCAN_HEBE_MESSAGE_BOXES)
|
onSuccess(ENDPOINT_VULCAN_HEBE_MESSAGE_BOXES)
|
||||||
}
|
}
|
||||||
|
@ -98,9 +98,6 @@ class VulcanHebeMessages(
|
|||||||
val receivers = message.getJsonArray("Receiver")
|
val receivers = message.getJsonArray("Receiver")
|
||||||
?.asJsonObjectList()
|
?.asJsonObjectList()
|
||||||
?: return@forEach
|
?: return@forEach
|
||||||
val receiverReadDate =
|
|
||||||
if (receivers.size == 1) readDate
|
|
||||||
else -1
|
|
||||||
|
|
||||||
for (receiver in receivers) {
|
for (receiver in receivers) {
|
||||||
val recipientId = if (messageType == TYPE_SENT)
|
val recipientId = if (messageType == TYPE_SENT)
|
||||||
@ -108,6 +105,8 @@ class VulcanHebeMessages(
|
|||||||
else
|
else
|
||||||
-1
|
-1
|
||||||
|
|
||||||
|
val receiverReadDate = receiver.getLong("HasRead", -1)
|
||||||
|
|
||||||
val messageRecipientObject = MessageRecipient(
|
val messageRecipientObject = MessageRecipient(
|
||||||
profileId,
|
profileId,
|
||||||
recipientId,
|
recipientId,
|
||||||
|
@ -24,7 +24,7 @@ class VulcanHebeMessagesChangeStatus(
|
|||||||
}
|
}
|
||||||
|
|
||||||
init { let {
|
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))
|
EventBus.getDefault().postSticky(MessageGetEvent(messageObject))
|
||||||
onSuccess()
|
onSuccess()
|
||||||
return@let
|
return@let
|
||||||
|
Loading…
Reference in New Issue
Block a user