mirror of
https://github.com/MisskeyIO/misskey
synced 2024-12-28 05:28:41 +09:00
30 lines
647 B
TypeScript
30 lines
647 B
TypeScript
import $ from 'cafy';
|
|
import User, { ILocalUser } from '../../../../models/user';
|
|
import { publishUserStream } from '../../../../stream';
|
|
|
|
export const meta = {
|
|
requireCredential: true,
|
|
secure: true
|
|
};
|
|
|
|
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
|
// Get 'home' parameter
|
|
const [home, homeErr] = $.arr($.obj({
|
|
name: $.str,
|
|
id: $.str,
|
|
place: $.str,
|
|
data: $.obj()
|
|
}).strict()).get(params.home);
|
|
if (homeErr) return rej('invalid home param');
|
|
|
|
await User.update(user._id, {
|
|
$set: {
|
|
'clientSettings.home': home
|
|
}
|
|
});
|
|
|
|
res();
|
|
|
|
publishUserStream(user._id, 'home_updated', home);
|
|
});
|