Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] added API endpoint for im.history.others, as advertised on rocket.chat REST API settings #13286

Closed
wants to merge 19 commits into from

Conversation

BlackFenix2
Copy link

This pull request adds an API endpoint for im.history.others as advertised on the rocket.chat REST API settings.

this was added to allow latest and oldest datetime parameters to be used for direct messages the user is not a part of.

image

@CLAassistant
Copy link

CLAassistant commented Jan 29, 2019

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@MarcosSpessatto MarcosSpessatto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BlackFenix2 can you add some tests for this endpoint?

@BlackFenix2
Copy link
Author

@MarcosSpessatto Sorry if this is a stupid question, where is the tests for the v1/im.history endpoint?

@BlackFenix2
Copy link
Author

@BlackFenix2
Copy link
Author

@BlackFenix2 can you add some tests for this endpoint?

I added a test for the API endpoint im.history.others. i basically copied the test for im.history, it should work under the same basic principle. Let me know if you need anything else.

@BlackFenix2
Copy link
Author

I see the Tests didn't like my PR :(. ill look over the endpoint and update the current branch.

@BlackFenix2
Copy link
Author

@MarcosSpessatto i might have a bit of an issue with this PR,

the value for RocketChat.settings.get('API_Enable_Direct_Message_History_EndPoint') is true inside the 'im.messages.others endpoint but is false on the "im.history.others" endpoint. the tests for both are set up exactly the same so i am not sure why this value is different.

@MarcosSpessatto
Copy link
Member

@BlackFenix2 sorry for the long delay, I'll take a look on this now.

@MarcosSpessatto
Copy link
Member

@BlackFenix2 it seems like the endpoint you are creating, already exists, but with another name, see here. Of course it is with the wrong name, based on what the setting in the admin panel says. Maybe we can only change the name of the endpoint in the description of the setting, or maybe we can depreciate the old endpoint(im.messages.others) and use your endpoint instead. Please let me know what you think.

@BlackFenix2
Copy link
Author

Wait a sec, I thought the endpoint 'im.messages.others' was the current endpoint. Are we looking to depreciate 'im.history.others'?

I was trying to find a way to search messages within a specific date/time range. Would I be better off coding against im.messages.others? I tried to use query expressions to get messages within a date/time range but I always got null.

@MarcosSpessatto
Copy link
Member

Wait a sec, I thought the endpoint 'im.messages.others' was the current endpoint. Are we looking to depreciate 'im.history.others'?

No, I told that we could depreciated im.messages.others and use the endpoint you are creating instead.

I was trying to find a way to search messages within a specific date/time range. Would I be better off coding against im.messages.others?

Yes, I think you can get the messages with this endpoint.

I tried to use query expressions to get messages within a date/time range but I always got null.

I don't know what server version you are running, because recently (v0.72) we introduce the EJSON structure to support these date queries, PR. Here you can see a little example searching by dates.

@BlackFenix2
Copy link
Author

oh, the query examples for date/time weren't listed last i checked.

i see my problem, i was using {"_updatedAt":{"$lt":"2018-12-21T15:27:28.202Z"}}

rather than {"_updatedAt":{"$lt":{"$date":"2018-12-21T15:27:28.202Z"}}}

since the intention of the PR was to sort messages by date-time, ill close out my PR since the functionality is redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants