Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

"inclusive" flag on REST API stopped working in 4.8.2

Open dmonn opened this issue 3 years ago • 1 comments

Description:

I've updated RocketChat from 4.6 to 4.8.2 last week. I've since then noticed that the im.history endpoint started behaving differently.

The inclusive flag in combination with oldest stopped working and if I query the IM history given the timestamp of the last message, I receive an empty response.

message = <last message object in "SOMEID" room>
messages = user_rock.im_history(room_id="SOMEID", count=20, unreads=True,  oldest=message['message']['ts'], inclusive=True).json()
>>> {'messages': [], 'success': True}

Instead, I need to query by messages send 1 millisecond before the last one, to get an inclusive result

message = <last message object in "SOMEID" room>
oldest = (datetime.datetime.strptime(message['message']['ts'], "%Y-%m-%dT%H:%M:%S.%fZ") - datetime.timedelta(milliseconds=1)).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
messages = user_rock.im_history(room_id="SOMEID", count=20, unreads=True,  oldest=oldest, inclusive=True).json()
>>> {'messages': [{...<result including 'message' object>...}], 'success': True}

Steps to reproduce:

  1. Try code on top with 4.6 & see that message itself is included
  2. Try again with 4.8.2 and see that it's excluded

Expected behavior:

Message should be included or API docs should be updated https://developer.rocket.chat/reference/api/rest-api/endpoints/core-endpoints/im-endpoints/history

Server Setup Information:

  • Version of Rocket.Chat Server: 4.8.2
  • Operating System: Ubuntu 18
  • Deployment Method: Docker

dmonn avatar Aug 08 '22 13:08 dmonn

Potentially fixed in #26438? Although seems like a different issue

dmonn avatar Aug 08 '22 13:08 dmonn