agora.observe.polls
Matrix polls (MSC3381) — construction and response parsing.
Element ships first-class UI for MSC3381 polls. We post m.poll.start with a
disclosed kind and a small list of options keyed by stable answer ids. Observers
click an option in Element; Element emits m.poll.response events that we
parse back into PollResponse structs.
Both the stable namespace (m.poll.*) and the unstable MSC3381 v1 namespace
(org.matrix.msc3381.poll.*) are handled, because older Element builds still
emit the unstable form.
Functions
|
Poll used by the planner to ask the user a blocking design question. |
|
Construct an MSC3381 stable-schema poll event content. |
|
Produce the |
For tests / fakes that need a placeholder poll event id. |
|
|
Parse an |
The Matrix event type to use when sending the poll. |
Classes
Parsed |
- class agora.observe.polls.PollResponse[source]
Bases:
objectParsed
m.poll.responseevent.- __init__(poll_event_id, user_id, answer_id, raw_event_id)
- agora.observe.polls.build_poll(question, options, *, fallback_verb='review')[source]
Construct an MSC3381 stable-schema poll event content.
optionsis a list of(answer_id, label)tuples.fallback_verbcontrols the plaintext/agora <verb> <id>hint embedded in the top-levelm.textfallback block (for clients without poll UI).Conforms to the MSC3381 stable schema: answer ids use the
m.idfield, text blocks usem.textarrays with{mimetype, body}variants, kind ism.disclosed, and the top-level fallback is anm.textarray (not abody``+``msgtypepair). The unstableorg.matrix.msc3381.poll.startdual-emit is NOT produced — current Element ignores it and earlier drafts of our own emitter included non-spec custom keys that caused Element to render empty bubbles.
- agora.observe.polls.build_review_poll(project_name, current_phase)[source]
Produce the
contentpayload for a review poll (5 fixed options).
- agora.observe.polls.build_decision_poll(question, options, decision_id)[source]
Poll used by the planner to ask the user a blocking design question.
decision_idis NOT stamped into the event content — some Element builds reject poll events with unknown top-level keys. Instead the tool-side code maintains apoll_event_id → decision_idmap in theOrchestratorControl, so responses route cleanly without polluting the wire event.
- agora.observe.polls.parse_poll_response(event)[source]
Parse an
m.poll.response(or unstable equivalent). ReturnsNoneif the event is malformed or not actually a poll response.