(client: MatrixClient, room: Room, opts: IOpts)
| 440 | } |
| 441 | |
| 442 | async function enableStateEventEncryption(client: MatrixClient, room: Room, opts: IOpts): Promise<void> { |
| 443 | // Don't send our state events until encryption is enabled. If this times |
| 444 | // out after 30 seconds, we throw since we don't want to send the events |
| 445 | // unencrypted. |
| 446 | await waitForRoomEncryption(room, 30000); |
| 447 | |
| 448 | // Set room name |
| 449 | if (opts.name) { |
| 450 | await client.setRoomName(room.roomId, opts.name); |
| 451 | } |
| 452 | |
| 453 | // Set room topic |
| 454 | if (opts.topic) { |
| 455 | const htmlTopic = htmlSerializeFromMdIfNeeded(opts.topic, { forceHTML: false }); |
| 456 | await client.setRoomTopic(room.roomId, opts.topic, htmlTopic); |
| 457 | } |
| 458 | |
| 459 | // Set room avatar |
| 460 | if (opts.avatar) { |
| 461 | let url: string; |
| 462 | if (opts.avatar instanceof File) { |
| 463 | ({ content_uri: url } = await client.uploadContent(opts.avatar)); |
| 464 | } else { |
| 465 | url = opts.avatar; |
| 466 | } |
| 467 | await client.sendStateEvent(room.roomId, EventType.RoomAvatar, { url }, ""); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | /** |
| 472 | * Wait until the supplied room has an `m.room.encryption` event, or time out |
no test coverage detected