mizzkey/src/server/api/endpoints/room/update.ts
YuzuRyo61 a07d753da8
APIドキュメントの改善 (#6757)
* Update api document in admin/announcements

* Update api document in announcements

* Update api document in i/read-announcements

* Update api document in username/available

* Update api document & Fix typo in API 403 error

* Update api document

* Update api document

* Update api document

* Fix API permission definition

* Update api document

* Update api document

* Update api document

* Update api document

* Update api document

* Update api document

* Update api document

* Update api document

* Fix bug in users (api)

* Apply reviews #6757

* Apply reviews #6757

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
2021-03-06 22:34:11 +09:00

52 lines
1,003 B
TypeScript

import $ from 'cafy';
import { publishMainStream } from '../../../../services/stream';
import define from '../../define';
import { Users, UserProfiles } from '../../../../models';
export const meta = {
tags: ['room'],
requireCredential: true as const,
params: {
room: {
validator: $.obj({
furnitures: $.arr($.obj({
id: $.str,
type: $.str,
position: $.obj({
x: $.num,
y: $.num,
z: $.num,
}),
rotation: $.obj({
x: $.num,
y: $.num,
z: $.num,
}),
props: $.optional.nullable.obj(),
})),
roomType: $.str,
carpetColor: $.str
})
},
},
};
export default define(meta, async (ps, user) => {
await UserProfiles.update(user.id, {
room: ps.room as any
});
const iObj = await Users.pack(user.id, user, {
detail: true,
includeSecrets: true
});
// Publish meUpdated event
publishMainStream(user.id, 'meUpdated', iObj);
// TODO: レスポンスがおかしいと思う by YuzuRyo61
return iObj;
});