30 lines
1.8 KiB
Markdown
30 lines
1.8 KiB
Markdown
|
|
# Fix IRC-Owncast Bridge Issues
|
||
|
|
|
||
|
|
## Task
|
||
|
|
Fix three issues: IRC username stripped in Owncast chat, WebSocket connection always failing, and echo suppression bug.
|
||
|
|
|
||
|
|
## Changes Made
|
||
|
|
|
||
|
|
### 1. HTML-escape username in IRC->Owncast messages (`src/router.rs`)
|
||
|
|
- Changed `<username>` to `<username>` in the formatted message sent to Owncast's chat API
|
||
|
|
- Owncast renders chat as HTML, so bare angle brackets were being interpreted as HTML tags and swallowed
|
||
|
|
|
||
|
|
### 2. Fix WebSocket authentication (`src/websocket.rs`, `src/owncast_api.rs`, `src/main.rs`)
|
||
|
|
- **Root cause**: Owncast's `/ws` endpoint requires an `accessToken` query parameter from a registered chat user. The bridge was connecting without one.
|
||
|
|
- Added `register_chat_user()` to `OwncastApiClient` -- calls `POST /api/chat/register` to get a user-level access token
|
||
|
|
- Updated `run_websocket_task` to register a chat user, cache the token, and pass it as `?accessToken=` in the WebSocket URL
|
||
|
|
- Token is cached across reconnections; re-registration happens only if rejected
|
||
|
|
- Added `base_url()` accessor to `OwncastApiClient`
|
||
|
|
|
||
|
|
### 3. Add `ws_display_name` config field (`src/config.rs`, `config.toml`, `config.example.toml`)
|
||
|
|
- New `ws_display_name` field on `OwncastConfig` (default: "IRC Bridge") controls the display name of the WebSocket chat user in Owncast
|
||
|
|
|
||
|
|
### 4. Fix echo suppression bug (`src/router.rs`)
|
||
|
|
- `record_sent` was storing the full formatted string (`[IRC] <nick> body`) but `is_echo` compared against raw `body` -- they never matched
|
||
|
|
- Changed `record_sent` to store the raw `body` so echo suppression actually works
|
||
|
|
- Moved the `is_echo` check before formatting in the Owncast->IRC path to avoid unnecessary work
|
||
|
|
|
||
|
|
## Follow-up Items
|
||
|
|
- Owncast admin still needs to configure webhook URL pointing to the bridge's port 9078
|
||
|
|
- The bridge's WebSocket user will appear as "IRC Bridge" in Owncast's connected users list
|