mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-15 11:43:09 +02:00
24 lines
556 B
TypeScript
24 lines
556 B
TypeScript
import $ from 'cafy';
|
|
import User from '../../../../models/user';
|
|
import event from '../../../../publishers/stream';
|
|
|
|
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
|
// Get 'home' parameter
|
|
const [home, homeErr] = $.arr(
|
|
$.obj.strict()
|
|
.have('name', $.str)
|
|
.have('id', $.str)
|
|
.have('data', $.obj))
|
|
.get(params.home);
|
|
if (homeErr) return rej('invalid home param');
|
|
|
|
await User.update(user._id, {
|
|
$set: {
|
|
'clientSettings.mobileHome': home
|
|
}
|
|
});
|
|
|
|
res();
|
|
|
|
event(user._id, 'mobile_home_updated', home);
|
|
});
|