-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Polls & Poll Answers #3248
Changes from all commits
c52b544
10c8db7
96088c0
b7a9ef6
70552ed
d99fb68
bb8b21b
0db3150
55baf04
29fe345
5982e11
5dfdf2b
fe98fea
727ebcf
c3071c9
69fe9bc
6ba9c3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"lexicon": 1, | ||
"id": "app.bsky.embed.poll", | ||
"defs": { | ||
"main": { | ||
"type": "object", | ||
"required": ["question", "options"], | ||
"properties": { | ||
"question": { | ||
"type": "string", | ||
"maxLength": 3000, | ||
"maxGraphemes": 300, | ||
"description": "The question being asked." | ||
}, | ||
"options": { | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"maxLength": 3000, | ||
"maxGraphemes": 300, | ||
"description": "The options available for the poll." | ||
}, | ||
"minLength": 1, | ||
"maxLength": 4 | ||
} | ||
} | ||
}, | ||
"view": { | ||
"type": "object", | ||
"required": ["question", "options"], | ||
"properties": { | ||
"question": { | ||
"type": "string", | ||
"maxLength": 3000, | ||
"maxGraphemes": 300, | ||
"description": "The question being asked." | ||
}, | ||
"options": { | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"maxLength": 3000, | ||
"maxGraphemes": 300, | ||
"description": "The options available for the poll." | ||
}, | ||
"minLength": 1, | ||
"maxLength": 4 | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,83 @@ | ||||||
{ | ||||||
"lexicon": 1, | ||||||
"id": "app.bsky.feed.getPollAnswers", | ||||||
"defs": { | ||||||
"main": { | ||||||
"type": "query", | ||||||
"description": "Get poll answers for a given poll which reference a post.", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think this is a bit confusing in terms of protocol design, since for example the poll could be edited out of a post and nothing is stopping a user from submitting a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a downside to the implementation I have put together so far. I considered instead creating an individual record called a Poll, which would then be associated with a Post, which could mitigate this. The issue I had with that is then you have this object that can only really ever have a relationship to a post, or can otherwise just be orphaned, and I figured that wouldn't be very useful. I'm open to changing this though! |
||||||
"parameters": { | ||||||
"type": "params", | ||||||
"required": ["uri"], | ||||||
"properties": { | ||||||
"uri": { | ||||||
"type": "string", | ||||||
"format": "at-uri", | ||||||
"description": "AT-URI of the subject (eg, a post record)." | ||||||
}, | ||||||
"cid": { | ||||||
"type": "string", | ||||||
"format": "cid", | ||||||
"description": "CID of the subject record (aka, specific version of record), to filter poll answers." | ||||||
}, | ||||||
"limit": { | ||||||
"type": "integer", | ||||||
"minimum": 1, | ||||||
"maximum": 100, | ||||||
"default": 50 | ||||||
}, | ||||||
"cursor": { | ||||||
"type": "string" | ||||||
} | ||||||
} | ||||||
}, | ||||||
"output": { | ||||||
"encoding": "application/json", | ||||||
"schema": { | ||||||
"type": "object", | ||||||
"required": ["uri"], | ||||||
"properties": { | ||||||
"uri": { | ||||||
"type": "string", | ||||||
"format": "at-uri" | ||||||
}, | ||||||
"cid": { | ||||||
"type": "string", | ||||||
"format": "cid" | ||||||
}, | ||||||
"cursor": { | ||||||
"type": "string" | ||||||
}, | ||||||
"pollAnswers": { | ||||||
"type": "array", | ||||||
"items": { | ||||||
"type": "ref", | ||||||
"ref": "#pollAnswer" | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
}, | ||||||
"pollAnswer": { | ||||||
"type": "object", | ||||||
"required": ["indexedAt", "createdAt", "actor", "answer"], | ||||||
"properties": { | ||||||
"indexedAt": { | ||||||
"type": "string", | ||||||
"format": "datetime" | ||||||
}, | ||||||
"createdAt": { | ||||||
"type": "string", | ||||||
"format": "datetime" | ||||||
}, | ||||||
"actor": { | ||||||
"type": "ref", | ||||||
"ref": "app.bsky.actor.defs#profileView" | ||||||
}, | ||||||
"answer": { | ||||||
"type": "integer" | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"lexicon": 1, | ||
"id": "app.bsky.feed.pollAnswer", | ||
"defs": { | ||
"main": { | ||
"type": "record", | ||
"description": "Record declaring a user's answer to a poll.", | ||
"key": "tid", | ||
"record": { | ||
"type": "object", | ||
"required": ["subject", "answer", "createdAt"], | ||
"properties": { | ||
"subject": { "type": "ref", "ref": "com.atproto.repo.strongRef" }, | ||
"createdAt": { "type": "string", "format": "datetime" }, | ||
"answer": { | ||
"type": "integer", | ||
"minimum": 1, | ||
"maximum": 15, | ||
"description": "The index of the option selected by the user." | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only covers single-choice polls in terms of poll definition.
Rather than a binary single-choice and any-number-of-choices system, it would be cool to have the maximum number of distinct selections given as an integer:
It should be specified what happens when the number is changed, but that's necessary anyway because multiple-choice polls (if/once allowed) can be edited into single-choice ones and vice versa. (The easiest solution would be to discard/disregard all previous answers when poll post content is edited of course, which is what Mastodon does I believe.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good to have too. I'm going to hold off on committing this in for now, as I would like to figure out the validation behavior that will allow this to work properly. Your mention of poll editing is key here. In the last question that I answered I was considering moving to having Polls be their own record, and, that may be necessary to handle poll editing properly, ensuring that PollAnswers are discarded, by nature of referencing a stale copy of the poll at edit time (that is to say, editing a poll would create a new poll record).