iceshrimp/src/server/api/endpoints/i/update_mobile_home.ts
2019-02-05 14:14:23 +09:00

33 lines
599 B
TypeScript

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