Add isolated ICQ presence shim (best-effort, TOC idle hint)

This commit is contained in:
Clay 2026-12-03 14:41:48 -05:00
parent b7ba76cc13
commit 4b2d856f58
3 changed files with 29 additions and 0 deletions

View file

@ -51,6 +51,7 @@ Against local open-oscar-server 0.25.0 with `DISABLE_AUTH=true`, TOC listener 98
- **UI overhaul (initial, 2026-12-02):** dark theme, sidebar sections as cards, conversations moved to tabs above chat window, message style toggle (Bubbles/Classic AIM-IRC) persisted in localStorage. Local static assets only, no build step. - **UI overhaul (initial, 2026-12-02):** dark theme, sidebar sections as cards, conversations moved to tabs above chat window, message style toggle (Bubbles/Classic AIM-IRC) persisted in localStorage. Local static assets only, no build step.
- **Recent UI/fix pass (2026-12-03):** CSP `upgrade-insecure-requests` disabled for HTTP deployments; TOC status label shows Connected/Disconnected; TOC-sent IMs broadcast into SSE buffer for replay on refresh; frontend `addMessage()` dedupes by msgId/recent same-sender text to prevent duplicate display; message input is textarea with Enter-to-send/Shift+Enter newline; buddy list shows per-person outlined rows with green/red/yellow status dots and handles `presence` updates. - **Recent UI/fix pass (2026-12-03):** CSP `upgrade-insecure-requests` disabled for HTTP deployments; TOC status label shows Connected/Disconnected; TOC-sent IMs broadcast into SSE buffer for replay on refresh; frontend `addMessage()` dedupes by msgId/recent same-sender text to prevent duplicate display; message input is textarea with Enter-to-send/Shift+Enter newline; buddy list shows per-person outlined rows with green/red/yellow status dots and handles `presence` updates.
- **Login hardening/UX (2026-12-03):** login page includes a simple server-side math bot check (`GET /api/auth/challenge`, validated on login) and configurable server host + Web API/TOC ports (defaults prefilled from env, Claytonia-friendly). Backend auth supports per-login Web API base/TOC host+port. - **Login hardening/UX (2026-12-03):** login page includes a simple server-side math bot check (`GET /api/auth/challenge`, validated on login) and configurable server host + Web API/TOC ports (defaults prefilled from env, Claytonia-friendly). Backend auth supports per-login Web API base/TOC host+port.
- **ICQ presence shim (2026-12-03, best-effort):** `src/icq-presence.js` applies conservative TOC hints for all-digit/ICQ UINs on signon (`toc_set_idle 0`) without changing AIM flow. ICQ online/offline visibility to others may still depend on open-oscar-server behavior.
- **Web API chat unavailable on 0.25.0:** do not rely on `/chat/*` Web API endpoints on this server. TOC is the working transport for chat/invites. - **Web API chat unavailable on 0.25.0:** do not rely on `/chat/*` Web API endpoints on this server. TOC is the working transport for chat/invites.
- **TOC is HTTP-mixed on 9898:** normal HTTP clients get 404; TOC clients must send `FLAPON\r\n\r\n` first. Any proxy in front of 9898 must pass raw TCP. - **TOC is HTTP-mixed on 9898:** normal HTTP clients get 404; TOC clients must send `FLAPON\r\n\r\n` first. Any proxy in front of 9898 must pass raw TCP.
- **No reliable all-users list:** Management API not exposed; `memberDir/search` returned empty. UI has direct "Start IM by screen name" flow. - **No reliable all-users list:** Management API not exposed; `memberDir/search` returned empty. UI has direct "Start IM by screen name" flow.

26
src/icq-presence.js Normal file
View file

@ -0,0 +1,26 @@
// src/icq-presence.js - isolated best-effort ICQ presence shim.
//
// Problem: AIM users see webui login/logout presence correctly, ICQ (all-digit UIN)
// users may not. OSCAR/TOC presence semantics can differ for ICQ; this module keeps
// any ICQ-specific nudges separate from the working AIM/TOC flow.
//
// Do not add guessing here. Only safe, documented TOC commands with clear intent.
// Wrapped in try/catch by caller so failures never break normal login.
export function isIcqScreenName(screenName) {
return /^\d+$/.test(String(screenName || '').trim());
}
// Best-effort: after TOC signon, nudge presence for ICQ UINs.
// toc_set_idle 0 is documented by TiK/Open OSCAR Server as "not idle at all".
export function applyIcqPresenceHints(rec, { logger = console } = {}) {
try {
if (!rec?.toc || !rec?.tocConnected) return;
if (!isIcqScreenName(rec.screenName)) return;
logger.info?.(`[icq-presence] applying TOC presence hints for ${rec.screenName}`);
rec.toc.sendCommand('toc_set_idle 0');
} catch (err) {
logger.warn?.('[icq-presence] hint failed:', err?.message || err);
}
}

View file

@ -5,6 +5,7 @@
import { TOCClient } from './toc.js'; import { TOCClient } from './toc.js';
import { bus } from './bus.js'; import { bus } from './bus.js';
import { broadcast } from './poller.js'; import { broadcast } from './poller.js';
import { applyIcqPresenceHints } from './icq-presence.js';
function normalize(sn) { function normalize(sn) {
return String(sn || '').toLowerCase().replace(/\s+/g, ''); return String(sn || '').toLowerCase().replace(/\s+/g, '');
@ -31,6 +32,7 @@ export async function startTOCSession(rec, { host, port, password }) {
lastError = ''; lastError = '';
console.log(`[toc] signed on ${rec.screenName}`); console.log(`[toc] signed on ${rec.screenName}`);
broadcast(rec, makeEvent('toc_status', { connected: true })); broadcast(rec, makeEvent('toc_status', { connected: true }));
try { applyIcqPresenceHints(rec, { logger: console }); } catch (err) { console.warn('[icq-presence] failed', err?.message || err); }
}); });
toc.on('close', () => { toc.on('close', () => {