Sharkey/src/server/api/endpoints/i/update_mobile_home.ts
syuilo d0570d7fe3
V10 (#2826)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update CHANGELOG.md

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update CHANGELOG.md

* Update CHANGELOG.md

* wip

* Update CHANGELOG.md

* wip

* wip

* wip

* wip
2018-10-07 11:06:17 +09:00

28 lines
642 B
TypeScript

import $ from 'cafy';
import User, { ILocalUser } from '../../../../models/user';
import { publishMainStream } 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,
data: $.obj()
}).strict()).get(params.home);
if (homeErr) return rej('invalid home param');
await User.update(user._id, {
$set: {
'clientSettings.mobileHome': home
}
});
res();
publishMainStream(user._id, 'mobileHomeUpdated', home);
});