gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

poll.go (3037B)


      1 // GoToSocial
      2 // Copyright (C) GoToSocial Authors admin@gotosocial.org
      3 // SPDX-License-Identifier: AGPL-3.0-or-later
      4 //
      5 // This program is free software: you can redistribute it and/or modify
      6 // it under the terms of the GNU Affero General Public License as published by
      7 // the Free Software Foundation, either version 3 of the License, or
      8 // (at your option) any later version.
      9 //
     10 // This program is distributed in the hope that it will be useful,
     11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 // GNU Affero General Public License for more details.
     14 //
     15 // You should have received a copy of the GNU Affero General Public License
     16 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18 package model
     19 
     20 // Poll represents a poll attached to a status.
     21 //
     22 // swagger:model poll
     23 type Poll struct {
     24 	// The ID of the poll in the database.
     25 	// example: 01FBYKMD1KBMJ0W6JF1YZ3VY5D
     26 	ID string `json:"id"`
     27 	// When the poll ends. (ISO 8601 Datetime), or null if the poll does not end
     28 	ExpiresAt string `json:"expires_at,omitempty"`
     29 	// Is the poll currently expired?
     30 	Expired bool `json:"expired"`
     31 	// Does the poll allow multiple-choice answers?
     32 	Multiple bool `json:"multiple"`
     33 	// How many votes have been received.
     34 	VotesCount int `json:"votes_count"`
     35 	// How many unique accounts have voted on a multiple-choice poll. Null if multiple is false.
     36 	VotersCount int `json:"voters_count,omitempty"`
     37 	// When called with a user token, has the authorized user voted?
     38 	Voted bool `json:"voted,omitempty"`
     39 	// When called with a user token, which options has the authorized user chosen? Contains an array of index values for options.
     40 	OwnVotes []int `json:"own_votes,omitempty"`
     41 	// Possible answers for the poll.
     42 	Options []PollOptions `json:"options"`
     43 	// Custom emoji to be used for rendering poll options.
     44 	Emojis []Emoji `json:"emojis"`
     45 }
     46 
     47 // PollOptions represents the current vote counts for different poll options.
     48 //
     49 // swagger:model pollOptions
     50 type PollOptions struct {
     51 	// The text value of the poll option. String.
     52 	Title string `json:"title"`
     53 	// The number of received votes for this option.
     54 	// Number, or null if results are not published yet.
     55 	VotesCount int `json:"votes_count,omitempty"`
     56 }
     57 
     58 // PollRequest models a request to create a poll.
     59 //
     60 // swagger:parameters createStatus
     61 type PollRequest struct {
     62 	// Array of possible answers.
     63 	// If provided, media_ids cannot be used, and poll[expires_in] must be provided.
     64 	// name: poll[options]
     65 	Options []string `form:"options" json:"options" xml:"options"`
     66 	// Duration the poll should be open, in seconds.
     67 	// If provided, media_ids cannot be used, and poll[options] must be provided.
     68 	ExpiresIn int `form:"expires_in" json:"expires_in" xml:"expires_in"`
     69 	// Allow multiple choices on this poll.
     70 	Multiple bool `form:"multiple" json:"multiple" xml:"multiple"`
     71 	// Hide vote counts until the poll ends.
     72 	HideTotals bool `form:"hide_totals" json:"hide_totals" xml:"hide_totals"`
     73 }