Rocket.chat: /api/v1/im.list.everyone does not return room usernames as before

Created on 27 Apr 2018  路  17Comments  路  Source: RocketChat/Rocket.Chat

Description:

/api/v1/im.list.everyone does not return room usernames as before.
I consumed this endpoint in the previous version (if I am not mistaken it is 0.58.3) and json was in accordance with the documentation.

Server Setup Information:

  • Version of Rocket.Chat Server: 0.63.1
  • Operating System: Linux
  • Deployment Method(snap/docker/tar/etc): docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Disabled
  • Node Version: v8.9.3
  • mongoDB Version:

Steps to Reproduce:

  1. Call like https://rocket.chat/docs/developer-guides/rest-api/im/list-everyone/

Expected behavior:

{
"ims": [
{
"_id": "ByehQjC44FwMeiLbX",
"name": "test-test",
"t": "p",
"usernames": [
"testing1"
],
"msgs": 0,
"u": {
"_id": "aobEdbYhXfu5hkeqG",
"username": "testing1"
},
"ts": "2016-12-09T15:08:58.042Z",
"ro": false,
"sysMes": true,
"_updatedAt": "2016-12-09T15:22:40.656Z"
},
{
"_id": "t7qapfhZjANMRAi5w",
"name": "testing",
"t": "p",
"usernames": [
"testing2"
],
"msgs": 0,
"u": {
"_id": "y65tAmHs93aDChMWu",
"username": "testing2"
},
"ts": "2016-12-01T15:08:58.042Z",
"ro": false,
"sysMes": true,
"_updatedAt": "2016-12-09T15:22:40.656Z"
}
],
"success": true
}

Actual behavior:

{
"ims": [
{
"_id":"etYwGz2mc5ZtmrFKZvhK8YPvPBd5HheQJw",
"_updatedAt":"2017-12-13T11:00:48.537Z",
"t":"d",
"msgs":373,
"ts":"2017-03-08T16:11:14.370Z",
"lm":"2017-12-13T11:00:48.501Z"
},
{
"_id":"u5yGHjwPb76szz3DozDg4Ky8vkYAeGPpji",
"_updatedAt":"2018-03-14T17:56:49.949Z",
"t":"d",
"msgs":138,
"ts":"2017-02-09T19:05:13.340Z",
"lm":"2018-03-14T17:56:49.802Z"
},
...
],
"offset":0,
"count":2980,
"total":2980,
"success":true
}

api rest

All 17 comments

As you can see here, this is the current structure: https://github.com/RocketChat/Rocket.Chat/blob/b5a8e2b04017d8e93a9a7b049c074e9e91aaf58b/packages/rocketchat-api/server/v1/im.js#L269-L274

count is the length of the array in ims, offset is the query defined in the request and total is the total amount of direct messages (including those that were not returned in the response).

I will update the docs

@mikaelmello thanks 馃憤

Hi.
Thanks for the quick response, but the problem is not with the offset, total or count, but with ims that not return the name of the room in usernames like before, leaving me lost in who is in that room.

@flavio80s You are right, sorry I missed that.

Honestly I don't know why this happens, did you try adding a fields field on your request body?

@graywolf336 maybe this sould be reopened

@mikaelmello fields only works in fields that are already part of the result.
When I tryed http://chat.vsm.com.br:3000/api/v1/im.list.everyone?fields={"usernames":1} it do nothing.
When I tryed http://chat.vsm.com.br:3000/api/v1/im.list.everyone?fields={"_id":0} it hide the _id field.

@flavio80s I guess I found out why

https://github.com/RocketChat/Rocket.Chat/blob/01d2aead1d9e61bb6752bde3e4728c677e41e38b/packages/rocketchat-api/server/api.js#L11-L18

The usernames field is set to be always excluded from queries for performance reasons (probably because of channels with a lot of users). Line 16 was added by @graywolf336 himself on https://github.com/RocketChat/Rocket.Chat/commit/75a4a62b8d7082d2d74f94e2d446b3b9632902bc so he certainly is better suited to tell you a workaround

Hi @graywolf336, is there any workaround to this situation?

@graywolf336 please reopen this issue.

@flavio80s sorry about that, the DM rooms should return the array of usernames cuz it will be only 2 always. @graywolf336 what do you think?

groups_list and groups_list_all does not return users also

@rodrigok unless we merge the pull request which allows direct messages between multiple users.

Channels and groups will not return the usernames array. Instead, you have to use the *.members endpoint.

I need that rooms of direct messages return the usernames, as it was before, not channels and groups.

For normal user IDs, you can also split the channel ID in two:
etYwGz2mc5ZtmrFKZvhK8YPvPBd5HheQJw would be an IM between etYwGz2mc5ZtmrFKZ and vhK8YPvPBd5HheQJw (both 17 chars long).
You'll still need to look those user IDs up though, and this may not always work as expected (for example, rocket.cat's ID is "rocket.cat" so an IM with it would be rocket.catYs8JWjD02JShd. Parsing that will be a lot harder, so this is not a perfect solution)

Why not just go back to the original behavior?
It is normal to discontinue a feature, but keeping it available with such incompatibility is unacceptable!
It worked very well as it was....

@flavio80s this is already fixed on recent versions.. please test on 0.68.4 ..

Thank you @sampaiodiego, I will test.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tanc picture tanc  路  3Comments

zeigerpuppy picture zeigerpuppy  路  3Comments

amayer5125 picture amayer5125  路  3Comments

mattlin picture mattlin  路  3Comments

djeber picture djeber  路  3Comments