refactor: remove /users/{uid}/settings/{setting} route

@baris Also, I am now allowing the following properties to be saved in User.saveSettings:
- categoryTopicSort
- topicPostSort
- setCategorySort
- setTopicSort
v1.18.x
Julian Lam 4 years ago
parent e0b6781776
commit aa8faf58a0

@ -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:

@ -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

@ -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 {

@ -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({

@ -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);

@ -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);

@ -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) {

Loading…
Cancel
Save