Refactor kstate resource uploading

This commit is contained in:
Cadence Ember 2024-06-06 12:12:48 +12:00
parent 07a133eba9
commit 24a3b9b0f4
7 changed files with 196 additions and 18 deletions

View file

@ -51,8 +51,8 @@ async function roomToKState(roomID) {
* @param {string} roomID
* @param {any} kstate
*/
function applyKStateDiffToRoom(roomID, kstate) {
const events = ks.kstateToState(kstate)
async function applyKStateDiffToRoom(roomID, kstate) {
const events = await ks.kstateToState(kstate)
return Promise.all(events.map(({type, state_key, content}) =>
api.sendState(roomID, type, state_key, content)
))
@ -220,7 +220,7 @@ async function createRoom(channel, guild, spaceID, kstate, privacyLevel) {
preset: PRIVACY_ENUMS.PRESET[privacyLevel], // This is closest to what we want, but properties from kstate override it anyway
visibility: PRIVACY_ENUMS.VISIBILITY[privacyLevel],
invite: [],
initial_state: ks.kstateToState(kstate),
initial_state: await ks.kstateToState(kstate),
...spaceCreationContent
})