-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Describe the bug
I'm trying to set up a self-hosted instance of Chatterbox in invite_user mode. When I first click on the Chatterbox button, it starts to open, creates the room, and sends the invitation, but then gets an error saying that room is undefined (t is undefined in the built version) and removes itself from the page. If I then reload the page and open Chatterbox again, it creates a second room, sends an invitation to that room, and works correctly from that point on. If I simulate being a new user (by clearing site data, opening a private window, or using a different browser), it fails again, then starts working again after a reload.
The error seems to be happening in Hydrogen's RoomViewModel class here, but that seems to be a result of Chatterbox passing in undefined as the room. I've managed to trace the problem to this part of createRoomWithUserSpecifiedInConfig:
chatterbox/src/viewmodels/ChatterboxViewModel.ts
Lines 78 to 95 in 86bc290
| const roomBeingCreated = this._session.createRoom({ | |
| type: 1, //todo: use enum from hydrogen-sdk here | |
| name: undefined, | |
| topic: undefined, | |
| isEncrypted: this._options.config["encrypt_room"] ?? false, | |
| isFederationDisabled: false, | |
| alias: undefined, | |
| avatar: undefined, | |
| invites: [userId], | |
| powerLevelContentOverride: powerLevelContent, | |
| }); | |
| const roomStatusObservable = await this._session.observeRoomStatus(roomBeingCreated.id); | |
| await roomStatusObservable.waitFor(status => status === (RoomStatus.BeingCreated | RoomStatus.Replaced)).promise; | |
| const roomId = roomBeingCreated.roomId; | |
| await this.platform.settingsStorage.setString("created-room-id", roomId); | |
| await this.platform.settingsStorage.setString("invite-user", userId); | |
| room = this._session.rooms.get(roomId); | |
| return room; |
this._sessions.rooms map is completely empty.
To Reproduce
Steps to reproduce the behavior:
- Download and extract chatterbox-v0.5.2.tar.gz.
- Edit config.json. Fill out the
homeserverandtokensettings. Replace theauto_join_roomsetting withinvite_user, and set it to a Matrix user ID that you control. - Create a basic index.html file, and add the embed code to it.
- Optional: The browser's devtools get confused when Chatterbox removes its
iframe, and won't let you look at the code that's failing anymore. To prevent this, addHTMLIFrameElement.prototype.remove = function() { console.log('refusing to remove iframe', this); };after theCHATTERBOX_CONFIG_LOCATIONline.
- Optional: The browser's devtools get confused when Chatterbox removes its
- Upload the contents of the
chatterbox-v0.5.2folder to a web server, or serve it onlocalhostusing something likehttplz. - Visit the server.
- Click on the Chatterbox button. It will open briefly and send the invite, then self-destruct.
OR
git clone https://github.com/element-hq/chatterbox; cd chatterbox- Edit public/config.json. Fill out the
homeserverandtokensettings. Replace theauto_join_roomsetting withinvite_user, and set it to a Matrix user ID that you control. yarn installyarn start- Visit http://localhost:5400/
- Click on the Chatterbox button. It will open briefly and send the invite, then self-destruct.
Expected behavior
Chatterbox should remain open after creating the room even if the user is opening it for the first time.
Screenshots
N/A. There's not really anything to take a screenshot of once Chatterbox removes itself.
Desktop (please complete the following information):
- OS: macOS
- Browser: Firefox, Chrome
- Version: Firefox 121.0.1, Chrome 120.0.6099.234
Smartphone (please complete the following information):
Not tested yet.
Device: [e.g. iPhone6]OS: [e.g. iOS8.1]Browser [e.g. stock browser, safari]Version [e.g. 22]
Additional context
I was originally testing with Chatterbox running on http://localhost:8000, but I've also tried running it from a real https:// site, and am getting the same results there. I'm running Chatterbox v0.5.2 (or 86bc290 when trying the dev build, but the only changes since v0.5.2 seem to be in the readme).
I have it set to use a self-hosted Synapse homeserver. When I first noticed the issue, invite_user was set to a user on a different self-hosted Synapse, but it seems to happen even if the invite_user is on the same server.