Skip to content

poll_create

poll_create is implemented by handlePollCreate in src/api/handlers/poll/poll_create.osl.

Creates a durable poll and its containing message. The public event is message_new, not poll_create. duration_hours is converted to an absolute Unix-seconds expires_at; an explicit expires_at is stored as supplied.

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 Yes. The transport removes the internal marker and filters recipients by channel visibility.

Every request includes cmd: "poll_create" 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
question required non-empty string; maximum 300 characters
options 2–10 strings or objects; normalized objects require id ≤ 50 and text ≤ 100
allow_multiselect optional boolean; defaults to false
expires_at optional absolute Unix timestamp in seconds
duration_hours optional positive number; used only when expires_at is absent

This adapter delegates validation to a shared helper. The field table lists values read directly by the handler; follow the collaborators below for the shared domain schema.

Shared validation and domain flow: src/api/helpers/polls/validation.osl.

  1. handleCmd enforces authentication.
  2. dispatchCmd routes poll_create to handlePollCreate.
  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, pollCreateData, randomUUID, pollCreate, pollSave, storedMessageSave, remove, pollPath, dbMessageToPublic, pollOptionsNormalize

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

Validation and domain failures use:

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