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_home.ts
2018-11-02 13:47:44 +09:00

34 lines
596 B
TypeScript

import $ from 'cafy';
import User from '../../../../models/user';
import { publishMainStream } from '../../../../stream';
import define from '../../define';
export const meta = {
requireCredential: true,
secure: true,
params: {
home: {
validator: $.arr($.obj({
name: $.str,
id: $.str,
place: $.str,
data: $.obj()
}).strict())
}
}
};
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
await User.update(user._id, {
$set: {
'clientSettings.home': ps.home
}
});
res();
publishMainStream(user._id, 'homeUpdated', ps.home);
}));