Skip to content

messages_get

messages_get is implemented by handleMessagesGet in src/api/handlers/message/messages_get.osl.

Returns the newest start + limit stored messages. In the current implementation, start increases the returned tail size; it is not subtracted as an offset, and the result is not trimmed back to limit.

Gate Requirement
Authentication Required by the central API gate.
Central permission None. Resource, channel, ownership, or hierarchy checks may still apply in the handler/helpers.
Broadcast Not marked global directly by this adapter. A helper may emit focused or server-wide updates.

Every request includes cmd: "messages_get" and may include an opaque listener correlation value.

Field Validation / meaning
channel string; defaults to an empty string
thread_id string; defaults to an empty string
start number or numeric string; defaults to 0; added to limit rather than used as an offset
limit number; defaults to 100; not capped or used to trim the final result

The handler and shared validation path use these OSL schema definitions before normalization:

*schema.Schema schemaMessagesGet = schema.object({
channel: schema.string().defaultValue(""),
thread_id: schema.string().defaultValue(""),
start: schema.union([
schema.number(),
schema.string()
]).defaultValue(0),
limit: schema.number().defaultValue(100)
})
  1. handleCmd enforces authentication.
  2. dispatchCmd routes messages_get to handleMessagesGet.
  3. The adapter validates and normalizes input, then calls its domain collaborators.
  4. Durable mutations complete before the response or event is returned.
  5. onMessage adds the request listener to direct responses and performs any marked broadcast.

Direct collaborators visible in the handler: messageContext, storedMessageTail, dbMessageToPublic, typeof

Response/event command names visible in this adapter: messages_get.

Validation and domain failures use:

{
"cmd": "error",
"val": "<message>",
"src": "messages_get",
"listener": "<copied from request>"
}