mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 21:13:08 +02:00
37 lines
635 B
TypeScript
37 lines
635 B
TypeScript
import $ from 'cafy';
|
|
import User from '../../../../models/user';
|
|
import { publishMainStream } from '../../../../stream';
|
|
import define from '../../define';
|
|
|
|
export const meta = {
|
|
requireCredential: true,
|
|
|
|
secure: true,
|
|
|
|
params: {
|
|
name: {
|
|
validator: $.str
|
|
},
|
|
|
|
value: {
|
|
validator: $.any.nullable
|
|
}
|
|
}
|
|
};
|
|
|
|
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
|
const x: any = {};
|
|
x[`clientSettings.${ps.name}`] = ps.value;
|
|
|
|
await User.update(user._id, {
|
|
$set: x
|
|
});
|
|
|
|
res();
|
|
|
|
// Publish event
|
|
publishMainStream(user._id, 'clientSettingUpdated', {
|
|
key: ps.name,
|
|
value: ps.value
|
|
});
|
|
}));
|