From 4b2d856f580790def89235a863542dc349b68e7a Mon Sep 17 00:00:00 2001 From: Clay Date: Thu, 3 Dec 2026 14:41:48 -0500 Subject: [PATCH] Add isolated ICQ presence shim (best-effort, TOC idle hint) --- HANDOFF.md | 1 + src/icq-presence.js | 26 ++++++++++++++++++++++++++ src/toc-session.js | 2 ++ 3 files changed, 29 insertions(+) create mode 100644 src/icq-presence.js diff --git a/HANDOFF.md b/HANDOFF.md index b2da00d..3e7bed7 100644 --- a/HANDOFF.md +++ b/HANDOFF.md @@ -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. - **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. +- **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. - **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. diff --git a/src/icq-presence.js b/src/icq-presence.js new file mode 100644 index 0000000..cf4ba8b --- /dev/null +++ b/src/icq-presence.js @@ -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); + } +} diff --git a/src/toc-session.js b/src/toc-session.js index 24b1bd2..993a253 100644 --- a/src/toc-session.js +++ b/src/toc-session.js @@ -5,6 +5,7 @@ import { TOCClient } from './toc.js'; import { bus } from './bus.js'; import { broadcast } from './poller.js'; +import { applyIcqPresenceHints } from './icq-presence.js'; function normalize(sn) { return String(sn || '').toLowerCase().replace(/\s+/g, ''); @@ -31,6 +32,7 @@ export async function startTOCSession(rec, { host, port, password }) { lastError = ''; console.log(`[toc] signed on ${rec.screenName}`); 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', () => {