Home Doh Ref
Dohballs
  • 📁 doh_chat
  • 📁 doh_modules
    • 📦 dataforge
    • 📦 express
    • 📁 sso
    • 📁 user

chat_files

File transfer subsystem for chat with P2P-first delivery and socket relay fallback.

What this module provides

Although chat_files has no standalone .doh.yaml, it is loaded through the chat package as:

  • node: chat_files_server
  • browser: chat_files_client

Server (chat_files_server.js)

Responsibilities:

  • initializes file tables in DB chat:
    • chat.files (metadata)
    • chat.file_seeds (who can serve each file)
  • enforces limits from Doh.pod.chat_files (size, chunking, timeout, cache caps)
  • writes file messages into chat.messages using [FILE] payload format
  • tracks room membership/guest access before allowing share/download flows

Socket events handled include:

  • chat:file:share
  • chat:file:request_peers
  • chat:file:signal (WebRTC offer/answer/ICE relay)
  • chat:file:relay_request, chat:file:relay_chunk, chat:file:relay_complete
  • chat:file:seed_registered
  • chat:file:probe (+ probe responses)

Client (chat_files_client.js)

Main pieces:

  • TransferManager orchestration for requesting/transferring files
  • FileCache (IndexedDB-backed local cache)
  • ChunkAccumulator for efficient chunk merge/finalization
  • ChatFileCard UI with transfer state, previews, cancel/download actions

Capabilities:

  • WebRTC data channel transfer with ICE servers from pod config
  • socket relay fallback when P2P cannot establish
  • media/text/pdf preview handling
  • optional media playback sync over chat socket
  • drag-and-drop integration with chat input surfaces

Configuration

Default pod keys are declared in Doh.Pod('chat_files_server', ...), including:

  • chunk_size
  • max_file_size
  • webrtc_timeout
  • relay_batch_size
  • cache_max_bytes
  • image_auto_download_max

Override in pod.yaml as needed.

Last updated: 2/17/2026