[NEW] Add user settings / preferences API endpoint#9457
[NEW] Add user settings / preferences API endpoint#9457rodrigok merged 30 commits intoRocketChat:developfrom
Conversation
|
@RocketChat/android @rocketchat/ios thoughts? This is probably something useful to you guys isn't it? |
|
@geekgonecrazy Yes, this is very useful for us, an API with all user settings would be welcome. 👍 Just one thing... shouldn't |
|
my bad there @rafaelks |
|
If it hasn't been said already... You rock! Thanks for being patient :) I'll look at creating a quick PR for the docs this weekend. All new rest endpoints we are trying to add a test and docs. That way developers don't have to dig for how to use these new endpoints. And ideally test keeps us from breaking the endpoint and not realizing it 😁 |
|
|
||
| RocketChat.API.v1.addRoute('users.getPreferences', { authRequired: true }, { | ||
| get() { | ||
| const user = this.getUserFromParams(); |
There was a problem hiding this comment.
You are still allowing to get data from any user you pass in params, you need to use the this.userId to find the logged user record
There was a problem hiding this comment.
Well @rodrigok this is a bit of a chicken and an egg situation, because if you check the file thoroughly, you will find that on 7 other methods we are defining the user in the same way. However, I do agree that we can narrow the scope down and enforce a more secure fashion.
So I'm changing that now and see if you like it. Thx!
|
@geekgonecrazy yes, I noticed that. And it's amazing how you guys improved documentation last couple of months. Sorry @MarcosSpessatto you had to pick up some tests writing for me. I will definitely look into writing tests. But I'm unaware of where to write the docs. If you give me pointers @geekgonecrazy I will definitely look into that too. Thx!! |
…PrefsEndPountRestAPI
|
|
||
| RocketChat.API.v1.addRoute('users.getPreferences', { authRequired: true }, { | ||
| get() { | ||
| const user = this.userId; |
There was a problem hiding this comment.
@jgtoriginal did you tested this? You will need to execute a find to get the user's object when you have the user's id
There was a problem hiding this comment.
@rodrigok no worries, will get to it at some point today and let you know.
Thanks very much!
There was a problem hiding this comment.
this has been solved by @MarcosSpessatto on 19a8ad6
added findOne call to retrieve the user, and remove verification which didn't allow false values to be saved
@jgtoriginal https://github.com/RocketChat/docs :) |
| RocketChat.API.v1.addRoute('users.getPreferences', { authRequired: true }, { | ||
| get() { | ||
| const user = this.userId; | ||
| const user = RocketChat.models.Users.findOneById(this.userId); |
There was a problem hiding this comment.
@MarcosSpessatto we are going back to what we previously had here, which @rodrigok asked to change for this.userId Any particular reason?
|
@MarcosSpessatto you just took over man!! Thank you very much!! |
|
@jgtoriginal i'll create docs now :) |
[NEW] Add user settings / preferences API endpoint #8694
Add a user settings / preferences endpoint to api, to make it possible to change user settings via authenticated api call.
@RocketChat/core
Closes #8694
@dennispost raised the concern of not being able to get and set user preferences via API.
@graywolf336 confirmed that such method didn't exist
I'm just providing a possible solution here.