Fix promises to be awaited
This commit is contained in:
parent
e706451d90
commit
5d5c751de8
@ -77,7 +77,7 @@ async function loadRcExport(entity: Entities) {
|
|||||||
log.debug('Mapping added:', mapping)
|
log.debug('Mapping added:', mapping)
|
||||||
|
|
||||||
// Add user to room mapping (specific to users)
|
// Add user to room mapping (specific to users)
|
||||||
Promise.all(
|
await Promise.all(
|
||||||
rcUser.__rooms.map(async (rcRoomId: string) => {
|
rcUser.__rooms.map(async (rcRoomId: string) => {
|
||||||
await createMembership(rcRoomId, rcUser._id)
|
await createMembership(rcRoomId, rcUser._id)
|
||||||
log.debug(`${rcUser.username} membership for ${rcRoomId} created`)
|
log.debug(`${rcUser.username} membership for ${rcRoomId} created`)
|
||||||
@ -123,11 +123,13 @@ async function main() {
|
|||||||
try {
|
try {
|
||||||
await whoami()
|
await whoami()
|
||||||
await initStorage()
|
await initStorage()
|
||||||
|
log.info('Parsing users')
|
||||||
await loadRcExport(Entities.Users)
|
await loadRcExport(Entities.Users)
|
||||||
|
log.info('Parsing rooms')
|
||||||
await loadRcExport(Entities.Rooms)
|
await loadRcExport(Entities.Rooms)
|
||||||
log.info('Done.')
|
log.info('Done.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(`Encountered an error while booting up: ${error}`)
|
log.error(`Encountered an error while booting up: ${error}`, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ export type MatrixRoom = {
|
|||||||
_creatorId?: string
|
_creatorId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mapRoom(rcRoom: RcRoom): MatrixRoom {
|
export async function mapRoom(rcRoom: RcRoom): Promise<MatrixRoom> {
|
||||||
const room: MatrixRoom = {
|
const room: MatrixRoom = {
|
||||||
creation_content: {
|
creation_content: {
|
||||||
'm.federate': false,
|
'm.federate': false,
|
||||||
@ -63,7 +63,7 @@ export function mapRoom(rcRoom: RcRoom): MatrixRoom {
|
|||||||
room._creatorId = rcRoom.uids?.[0] || ''
|
room._creatorId = rcRoom.uids?.[0] || ''
|
||||||
|
|
||||||
if (rcRoom.uids) {
|
if (rcRoom.uids) {
|
||||||
Promise.all(
|
await Promise.all(
|
||||||
rcRoom.uids.map(async (uid) => {
|
rcRoom.uids.map(async (uid) => {
|
||||||
await createMembership(rcRoom._id, uid)
|
await createMembership(rcRoom._id, uid)
|
||||||
log.debug(`${uid} membership in direct chat ${rcRoom._id} created`)
|
log.debug(`${uid} membership in direct chat ${rcRoom._id} created`)
|
||||||
@ -100,7 +100,7 @@ export function mapRoom(rcRoom: RcRoom): MatrixRoom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function createRoom(rcRoom: RcRoom): Promise<MatrixRoom> {
|
export async function createRoom(rcRoom: RcRoom): Promise<MatrixRoom> {
|
||||||
const room: MatrixRoom = mapRoom(rcRoom)
|
const room: MatrixRoom = await mapRoom(rcRoom)
|
||||||
let sessionOptions = {}
|
let sessionOptions = {}
|
||||||
if (room._creatorId) {
|
if (room._creatorId) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user