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.
Access
Section titled “Access”| 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. |
Request
Section titled “Request”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 |
Validator source
Section titled “Validator source”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.
Processing path
Section titled “Processing path”handleCmdenforces authentication.dispatchCmdroutespoll_createtohandlePollCreate.- The adapter validates and normalizes input, then calls its domain collaborators.
- Durable mutations complete before the response or event is returned.
onMessageadds 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
Responses and events
Section titled “Responses and events”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>"}