fix: HTML-escape IRC username in Owncast chat, fix WebSocket auth, fix echo suppression
- Escape angle brackets around IRC username so Owncast doesn't swallow them as HTML tags (<nick> instead of <nick>) - Register a chat user via POST /api/chat/register to obtain an accessToken, then pass it as a query param when connecting to /ws (Owncast closes the WebSocket immediately without one) - Cache the access token across reconnections; re-register only on rejection - Add ws_display_name config option (default "IRC Bridge") - Fix echo suppression: record_sent and is_echo now both compare raw body instead of mismatched formatted/raw values Made-with: Cursor
This commit is contained in:
29
chat-summaries/2026-03-10_21-30-summary.md
Normal file
29
chat-summaries/2026-03-10_21-30-summary.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# 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
|
||||
Reference in New Issue
Block a user