mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-11-19 03:16:35 +01:00
25 lines
599 B
TypeScript
25 lines
599 B
TypeScript
import $ from 'cafy';
|
|
import User, { ILocalUser } from '../../../../models/user';
|
|
import event from '../../../../publishers/stream';
|
|
|
|
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
|
// Get 'home' parameter
|
|
const [home, homeErr] = $.arr(
|
|
$.obj.strict()
|
|
.have('name', $.str)
|
|
.have('id', $.str)
|
|
.have('place', $.str)
|
|
.have('data', $.obj))
|
|
.get(params.home);
|
|
if (homeErr) return rej('invalid home param');
|
|
|
|
await User.update(user._id, {
|
|
$set: {
|
|
'clientSettings.home': home
|
|
}
|
|
});
|
|
|
|
res();
|
|
|
|
event(user._id, 'home_updated', home);
|
|
});
|