1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-23 11:08:36 +09:00
misskey/src/server/api/endpoints/i/update_mobile_home.ts
2018-07-07 19:19:00 +09:00

24 lines
550 B
TypeScript

import $ from 'cafy';
import User, { ILocalUser } from '../../../../models/user';
import event from '../../../../stream';
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'home' parameter
const [home, homeErr] = $.arr($.obj({
name: $.str,
id: $.str,
data: $.obj()
}).strict()).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);
});