Fix error for duplicate room memberships

This commit is contained in:
Henrik Hüttemann 2023-06-13 12:32:11 +02:00
parent 5d5c751de8
commit 4a54b63cc0
No known key found for this signature in database
GPG Key ID: 9F7BD10E0A8A111E

View File

@ -64,10 +64,13 @@ export async function mapRoom(rcRoom: RcRoom): Promise<MatrixRoom> {
if (rcRoom.uids) { if (rcRoom.uids) {
await Promise.all( await Promise.all(
rcRoom.uids.map(async (uid) => { [...new Set(rcRoom.uids)] // Deduplicate users
await createMembership(rcRoom._id, uid) .map(async (uid) => {
log.debug(`${uid} membership in direct chat ${rcRoom._id} created`) await createMembership(rcRoom._id, uid)
}) log.debug(
`${uid} membership in direct chat ${rcRoom._id} created`
)
})
) )
} else { } else {
throw new Error('Found a direct chat without uids. This is unexpected.') throw new Error('Found a direct chat without uids. This is unexpected.')