summaryrefslogtreecommitdiff
path: root/internal/api/model
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-11-08 14:32:17 +0000
committerLibravatar GitHub <noreply@github.com>2023-11-08 14:32:17 +0000
commite9e5dc5a40926e5320cb131b035c46b1e1b0bd59 (patch)
tree52edc9fa5742f28e1e5223f51cda628ec1c35a24 /internal/api/model
parent[chore]: Bump github.com/spf13/cobra from 1.7.0 to 1.8.0 (#2338) (diff)
downloadgotosocial-e9e5dc5a40926e5320cb131b035c46b1e1b0bd59.tar.xz
[feature] add support for polls + receiving federated status edits (#2330)
Diffstat (limited to 'internal/api/model')
-rw-r--r--internal/api/model/poll.go41
1 files changed, 31 insertions, 10 deletions
diff --git a/internal/api/model/poll.go b/internal/api/model/poll.go
index 2f9ce7476..ca479d117 100644
--- a/internal/api/model/poll.go
+++ b/internal/api/model/poll.go
@@ -24,35 +24,44 @@ type Poll struct {
// The ID of the poll in the database.
// example: 01FBYKMD1KBMJ0W6JF1YZ3VY5D
ID string `json:"id"`
- // When the poll ends. (ISO 8601 Datetime), or null if the poll does not end
- ExpiresAt string `json:"expires_at,omitempty"`
+
+ // When the poll ends. (ISO 8601 Datetime).
+ ExpiresAt string `json:"expires_at"`
+
// Is the poll currently expired?
Expired bool `json:"expired"`
+
// Does the poll allow multiple-choice answers?
Multiple bool `json:"multiple"`
+
// How many votes have been received.
VotesCount int `json:"votes_count"`
- // How many unique accounts have voted on a multiple-choice poll. Null if multiple is false.
- VotersCount int `json:"voters_count,omitempty"`
+
+ // How many unique accounts have voted on a multiple-choice poll.
+ VotersCount int `json:"voters_count"`
+
// When called with a user token, has the authorized user voted?
Voted bool `json:"voted,omitempty"`
+
// When called with a user token, which options has the authorized user chosen? Contains an array of index values for options.
OwnVotes []int `json:"own_votes,omitempty"`
+
// Possible answers for the poll.
- Options []PollOptions `json:"options"`
+ Options []PollOption `json:"options"`
+
// Custom emoji to be used for rendering poll options.
Emojis []Emoji `json:"emojis"`
}
-// PollOptions represents the current vote counts for different poll options.
+// PollOption represents the current vote counts for different poll options.
//
-// swagger:model pollOptions
-type PollOptions struct {
+// swagger:model pollOption
+type PollOption struct {
// The text value of the poll option. String.
Title string `json:"title"`
+
// The number of received votes for this option.
- // Number, or null if results are not published yet.
- VotesCount int `json:"votes_count,omitempty"`
+ VotesCount int `json:"votes_count"`
}
// PollRequest models a request to create a poll.
@@ -63,11 +72,23 @@ type PollRequest struct {
// If provided, media_ids cannot be used, and poll[expires_in] must be provided.
// name: poll[options]
Options []string `form:"options" json:"options" xml:"options"`
+
// Duration the poll should be open, in seconds.
// If provided, media_ids cannot be used, and poll[options] must be provided.
ExpiresIn int `form:"expires_in" json:"expires_in" xml:"expires_in"`
+
// Allow multiple choices on this poll.
Multiple bool `form:"multiple" json:"multiple" xml:"multiple"`
+
// Hide vote counts until the poll ends.
HideTotals bool `form:"hide_totals" json:"hide_totals" xml:"hide_totals"`
}
+
+// PollVoteRequest models a request to vote in a poll.
+//
+// swagger:parameters pollVote
+type PollVoteRequest struct {
+ // Choices contains poll vote choice indices. Note that form
+ // uses a different key than the JSON, i.e. the '[]' suffix.
+ Choices []int `form:"choices[]" json:"choices" xml:"choices"`
+}