diff options
Diffstat (limited to 'src/server/api/endpoints/room/update.ts')
| -rw-r--r-- | src/server/api/endpoints/room/update.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/server/api/endpoints/room/update.ts b/src/server/api/endpoints/room/update.ts new file mode 100644 index 0000000000..897f65f2d2 --- /dev/null +++ b/src/server/api/endpoints/room/update.ts @@ -0,0 +1,48 @@ +import $ from 'cafy'; +import { publishMainStream } from '../../../../services/stream'; +import define from '../../define'; +import { Users, UserProfiles } from '../../../../models'; + +export const meta = { + requireCredential: true, + + 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({ userId: 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); + + return iObj; +}); |