Previously the the API would always return an JSON_ARRAY, even when there were just one user that starred a message.
In the latest RC version (0.70.0) this changed and now the API sends an JSON_OBJECT when there is only one star, and JSON_ARRAY when there is more than one.
Android can't handle this very well, we expect that a API field is ALWAYS the same type, always a String, or always a boolean, or always an array or an object, but never multiple types for the same field name.
loadMissingMessages D Error fetching channel history
D chat.rocket.common.RocketChatInvalidResponseException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at path $.messages[0].starred(url='https://open.rocket.chat/api/v1/dm.history?roomId=*******&count=50&oldest=2018-09-21T15%3A21%3A49.646Z')
D at chat.rocket.core.internal.rest.RestClientKt.handleResponse(RestClient.kt:76)
@luciofm the code that returns the messages was not changed since 2 years ago.
Can you show examples of the return of these 2 situations?
@rodrigok FYI he's talking about the REST API, not the WebSocket method.
@rafaelks the endpoint described above was another: /api/v1/dm.history
@rafaelks as @MarcosSpessatto said, Lucio posted a call for dm.history which calls that Meteor method.
The dm.history should always return an object, the REST channels.messages should always return an array, and the last message should always return an array.
The problem here is that we are not processing the starred array on that 2 places and we should since we should only return the user's stars, and the message contains the stars of all users who starred the message.
I already talked with @sampaiodiego and he will organize how to solve this.
I've changed the issue title to reflect the issue.
Most helpful comment
I've changed the issue title to reflect the issue.