Document the api layer's operational models, and fix two headers that had gone stale against the code
This commit is contained in:
@@ -4,12 +4,19 @@
|
||||
// The Partnership tab's mesh chat: read a channel, post to it, forget a message on this
|
||||
// machine, and mark a channel read.
|
||||
//
|
||||
// REQUEST
|
||||
// GET channels + this host's id + unread counts
|
||||
// GET ?channel=<id> that channel's messages
|
||||
// POST action=send channel=<id> text=… [color=#rrggbb] [font=mono|sans|serif]
|
||||
// POST action=delete channel=<id> id=<msgid> local only
|
||||
// POST action=read channel=<id> mark seen up to now
|
||||
// OPERATIONAL MODEL
|
||||
// The method is the routing. Anything that is not a POST is a read — channel list or one
|
||||
// channel's messages — and every POST carries an action. That keeps the CSRF boundary and the
|
||||
// read/write boundary on the same line, so a mutation cannot arrive un-covered by being
|
||||
// spelled as a GET.
|
||||
//
|
||||
// Reads are computed per request, not cached. Unread counts come from walking the last 200
|
||||
// messages of each channel against this host's read mark; the card polls on a slow cycle and
|
||||
// the store is a small append log, so a cache would add a staleness class for no gain.
|
||||
//
|
||||
// Delivery is not part of the response's success. vv_nc_send() writes locally and spools for
|
||||
// any partner that could not be reached, and the reply carries that spool depth as `queued`.
|
||||
// A sleeping partner is a pending message, not a failed one.
|
||||
//
|
||||
// DESIGN PRINCIPLES
|
||||
// Read marks are local and per channel. "Unread" is a fact about this operator at this
|
||||
@@ -28,6 +35,22 @@
|
||||
// locally and spooled for retry; saying "failed" over something that is stored and queued
|
||||
// would be the wrong claim.
|
||||
//
|
||||
// REQUEST
|
||||
// GET channels + this host's id + unread counts
|
||||
// GET ?channel=<id> that channel's messages
|
||||
// POST action=send channel=<id> text=… [color=#rrggbb] [font=mono|sans|serif]
|
||||
// POST action=delete channel=<id> id=<msgid> local only
|
||||
// POST action=read channel=<id> mark seen up to now
|
||||
//
|
||||
// RESPONSE
|
||||
// {"ok":true,"me":<host>,"channels":[{…,"unread":N}],"hostnames":{id:name}} channel list
|
||||
// {"ok":true,"me":<host>,"channel":<id>,"messages":[…],"last_read":<ts>} one channel
|
||||
// {"ok":true,"msg":{…},"queued":N} send; N = spooled
|
||||
// {"ok":true|false} delete
|
||||
// {"ok":true} read
|
||||
// {"ok":false,"error":"Unknown channel"|"Nothing to send"|"Could not store message"
|
||||
// |"No message id"|"Unknown action"}
|
||||
//
|
||||
// DEPENDS ON
|
||||
// include/node_chat.php
|
||||
// ═══════════════════════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user