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

[NEW] Add user settings / preferences API endpoint #9457

Merged
merged 30 commits into from
Feb 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1b8483f
Add user settings / preferences API endpoint #8694
jgtoriginal Jan 21, 2018
f30d581
Thx coday bot: missing semicolons
jgtoriginal Jan 21, 2018
28b2993
Thx coday bot: property shorthand expected
jgtoriginal Jan 21, 2018
c8f843b
unneded ;
jgtoriginal Jan 21, 2018
b2c75b4
making tests happy
jgtoriginal Jan 21, 2018
c5c2042
updating mongo
jgtoriginal Jan 22, 2018
01f499f
missing semicolon
jgtoriginal Jan 22, 2018
e0c2b8f
formatting
jgtoriginal Jan 22, 2018
c99bfcc
formatting
jgtoriginal Jan 22, 2018
c797214
formatting
jgtoriginal Jan 22, 2018
4cc4c48
formatting
jgtoriginal Jan 22, 2018
3c5077a
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into user…
jgtoriginal Jan 22, 2018
d0d7f59
users.getPreferences always requires authentication
jgtoriginal Jan 23, 2018
1df340e
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into user…
jgtoriginal Feb 15, 2018
58d744f
fixing conflicts
jgtoriginal Feb 15, 2018
e336ddb
going by single quotes
jgtoriginal Feb 15, 2018
cee2461
default to the user registered if none is passed
jgtoriginal Feb 16, 2018
b3295a5
adding new params requested by @karlprieb
jgtoriginal Feb 16, 2018
f203b27
get own preferences only
jgtoriginal Feb 16, 2018
9adf9fc
adding muteFocusedConversations param on @karlprieb request
jgtoriginal Feb 16, 2018
2db5a94
giving a more sensible error message
jgtoriginal Feb 16, 2018
e36f95d
replacing this.getUserFromParams() for this.userId, due to legit secu…
jgtoriginal Feb 17, 2018
c964116
fixing typo on i18n
jgtoriginal Feb 17, 2018
3132664
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into user…
jgtoriginal Feb 17, 2018
82e9c42
Merge branch 'DeprecationWarning' into userPrefsEndPountRestAPI
jgtoriginal Feb 17, 2018
5871eb8
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into user…
jgtoriginal Feb 17, 2018
19a8ad6
added findOne call to retrieve the user, and remove verification whic…
MarcosSpessatto Feb 20, 2018
d81d1f7
added tests for this endpoint
MarcosSpessatto Feb 20, 2018
68ceaf7
fix test about getPreferences endpoint
MarcosSpessatto Feb 20, 2018
6e47d51
Merge branch 'develop' into userPrefsEndPountRestAPI
rodrigok Feb 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/rocketchat-api/server/v1/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor Author

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?

if (user.settings) {
const preferences = user.settings.preferences;
preferences['language'] = user.language;
Expand Down
7 changes: 1 addition & 6 deletions packages/rocketchat-lib/server/functions/saveUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,7 @@ RocketChat.saveUser = function(userId, userData) {
}

if (userData.settings) {
updateUser.$set.settings = { preferences: {} };
for (const key in userData.settings.preferences) {
if (userData.settings.preferences[key]) {
updateUser.$set.settings.preferences[key] = userData.settings.preferences[key];
}
}
updateUser.$set.settings = { preferences: userData.settings.preferences };
}

if (typeof userData.requirePasswordChange !== 'undefined') {
Expand Down