diff --git a/public/openapi/write.yaml b/public/openapi/write.yaml index 3d880ce060..35fed4b3fe 100644 --- a/public/openapi/write.yaml +++ b/public/openapi/write.yaml @@ -34,8 +34,6 @@ paths: $ref: 'write/users/uid.yaml' /users/{uid}/settings: $ref: 'write/users/uid/settings.yaml' - /users/{uid}/settings/{setting}: - $ref: 'write/users/uid/settings/setting.yaml' /users/{uid}/password: $ref: 'write/users/uid/password.yaml' /users/{uid}/follow: diff --git a/public/openapi/write/users/uid/settings/setting.yaml b/public/openapi/write/users/uid/settings/setting.yaml deleted file mode 100644 index 455eb787dd..0000000000 --- a/public/openapi/write/users/uid/settings/setting.yaml +++ /dev/null @@ -1,40 +0,0 @@ -put: - tags: - - users - summary: update one user setting - parameters: - - in: path - name: uid - schema: - type: integer - required: true - description: uid of the user - example: '1' - - in: path - name: setting - schema: - type: string - required: true - description: name of the setting you wish to update - example: 'showemail' - requestBody: - content: - application/json: - schema: - type: object - properties: - value: - type: string - example: '1' - responses: - '200': - description: successfully updated user settings - content: - application/json: - schema: - type: object - properties: - status: - $ref: ../../../../components/schemas/Status.yaml#/Status - response: - type: object \ No newline at end of file diff --git a/public/src/modules/sort.js b/public/src/modules/sort.js index c4dda1e5e3..de83eb49d1 100644 --- a/public/src/modules/sort.js +++ b/public/src/modules/sort.js @@ -20,9 +20,9 @@ define('sort', ['components', 'api'], function (components, api) { } var newSetting = $(this).attr('data-sort'); if (app.user.uid) { - api.put(`/users/${app.user.uid}/settings/${field}`, { - value: newSetting, - }).then(() => { + const payload = { settings: {} }; + payload.settings[field] = newSetting; + api.put(`/users/${app.user.uid}/settings`, payload).then(() => { refresh(newSetting, utils.params()); }); } else { diff --git a/src/api/users.js b/src/api/users.js index 0379bdcd96..5d04a88406 100644 --- a/src/api/users.js +++ b/src/api/users.js @@ -106,10 +106,6 @@ usersAPI.updateSettings = async function (caller, data) { return await user.saveSettings(data.uid, payload); }; -usersAPI.updateSetting = async function (caller, data) { - await user.setSetting(data.uid, data.setting, data.value); -}; - usersAPI.changePassword = async function (caller, data) { await user.changePassword(caller.uid, Object.assign(data, { ip: caller.ip })); await events.log({ diff --git a/src/controllers/write/users.js b/src/controllers/write/users.js index 3c9d1618ab..afb3b72ea2 100644 --- a/src/controllers/write/users.js +++ b/src/controllers/write/users.js @@ -33,11 +33,6 @@ Users.updateSettings = async (req, res) => { helpers.formatApiResponse(200, res, settings); }; -Users.updateSetting = async (req, res) => { - await api.users.updateSetting(req, { ...req.params, value: req.body.value }); - helpers.formatApiResponse(200, res); -}; - Users.changePassword = async (req, res) => { await api.users.changePassword(req, { ...req.body, uid: req.params.uid }); helpers.formatApiResponse(200, res); diff --git a/src/routes/write/users.js b/src/routes/write/users.js index 7894a82517..86d06954fc 100644 --- a/src/routes/write/users.js +++ b/src/routes/write/users.js @@ -22,7 +22,6 @@ function authenticatedRoutes() { setupApiRoute(router, 'delete', '/:uid', [...middlewares, middleware.assert.user, middleware.exposePrivileges], controllers.write.users.delete); setupApiRoute(router, 'put', '/:uid/settings', [...middlewares, middleware.checkRequired.bind(null, ['settings'])], controllers.write.users.updateSettings); - setupApiRoute(router, 'put', '/:uid/settings/:setting', [...middlewares, middleware.checkRequired.bind(null, ['value'])], controllers.write.users.updateSetting); setupApiRoute(router, 'put', '/:uid/password', [...middlewares, middleware.checkRequired.bind(null, ['newPassword']), middleware.assert.user], controllers.write.users.changePassword); diff --git a/src/user/settings.js b/src/user/settings.js index 8035896fd2..d3dec1cb6d 100644 --- a/src/user/settings.js +++ b/src/user/settings.js @@ -121,6 +121,10 @@ module.exports = function (User) { upvoteNotifFreq: data.upvoteNotifFreq, bootswatchSkin: data.bootswatchSkin, categoryWatchState: data.categoryWatchState, + categoryTopicSort: data.categoryTopicSort, + topicPostSort: data.topicPostSort, + setCategorySort: data.setCategorySort, + setTopicSort: data.setTopicSort, }; const notificationTypes = await notifications.getAllNotificationTypes(); notificationTypes.forEach(function (notificationType) {