Chat REST API endpoint changes
-
In the last versions of NodeBB you have changed the chats endpoint for your REST API from: /api/chats to /api/user/{userslug}/chats.
It doesnt make any sense. Now, a third party app which uses the REST API needs to get the userslug or do a manual redirect to the new endpoint. It doesnt make any sense since the chat rooms for the logged user must be retrieved easily by making a simple request to /api/chats. Just like it was before and just like you must do to get the notifications (/api/notifications).
Please, bring back the usual endpoint.
-
It's not a big deal.
/api/chats
returns the relative url you need, so doing something like this isn't hard:fetch('/api/chats') .then(body => body.text()) .then(url => fetch(url)) .then(body => body.json()) .then(result => { // do something with your resulting object });
-
@PitaJ said in Chat REST API endpoint changes:
It's not a big deal.
/api/chats
returns the relative url you need, so doing something like this isn't hard:fetch('/api/chats') .then(body => body.text()) .then(url => fetch(url)) .then(body => body.json()) .then(result => { // do something with your resulting object });
Yeah, it is not difficult, but it is totally illogic. If you do a API REST, please, do it well or don't do it. It's obvious that /api/chats will show actual logged user chats. It is not necessary to add the username in the endpoint url. An user cannot read other users chats, it is absurd.
Yes you can do two requests to fetch the user chats, you can do all the request you want, why do you not add more? If you are developing a mobile app to use the REST API, it doesn't matter how many request you do, it doesn't matter if your app consume all the data the user has contracted.
Yes, it's not difficult to make two or more request, but it is not efficient, and it isn't a well designed API. To do a bad API, don't do anything and save your time.
Also, if you think that it is well designed, please, do all your API equal. /api/notifications should be /api/user/{userslug}/notifications if we follow the same logic. It is bad designed, but at least follow the same logic.
-
@alberto__segura this was changed precisely to allow admins to look through other user's chats. That's why this was necessary.
You're just being anal over such a small thing. Deal with it.
-
@PitaJ said in Chat REST API endpoint changes:
@alberto__segura this was changed precisely to allow admins to look through other user's chats. That's why this was necessary.
You're just being anal over such a small thing. Deal with it.
Oh, i didn't realized admins can now read user private conversations. Now it have more sense. Anyway, the usual endpoint should work for the actual logged user. Also, I don't like the admins could directly read other users conversations
-
@alberto__segura said in Chat REST API endpoint changes:
Also, I don't like the admins could directly read other users conversations
It was removed and code moved to a plugin. So, admins can read other users conversations if the plugin is installed.