-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
[NEW] Add user settings / preferences API endpoint #9457
[NEW] Add user settings / preferences API endpoint #9457
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 |
@@ -271,6 +271,77 @@ RocketChat.API.v1.addRoute('users.createToken', { authRequired: true }, { | |||
} | |||
}); | |||
|
|||
RocketChat.API.v1.addRoute('users.getPreferences', { authRequired: true }, { | |||
get() { | |||
const user = this.getUserFromParams(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -271,6 +271,77 @@ RocketChat.API.v1.addRoute('users.createToken', { authRequired: true }, { | |||
} | |||
}); | |||
|
|||
RocketChat.API.v1.addRoute('users.getPreferences', { authRequired: true }, { | |||
get() { | |||
const user = this.userId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has been solved by @MarcosSpessatto on 19a8ad6
…h didn't allow false values to be saved
|
@@ -273,7 +273,7 @@ RocketChat.API.v1.addRoute('users.createToken', { authRequired: true }, { | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.