summaryrefslogtreecommitdiffstats
path: root/src/entities/poll.rs
blob: e51a04a21e1528de688689f00e4268907ec7a1a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::entities::status::Emoji;
use serde::{Deserialize, Serialize};

/// Represents a poll attached to a status.
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct Poll {
    /// The ID of the poll in the database.
    pub id: String,
    /// When the poll ends.
    pub expires_at: String, // Datetime??
    /// Is the poll currently expired?
    pub expired: bool,
    /// Does the poll allow multiple-choice answers?
    pub multiple: bool,
    /// How many votes have been received.
    pub votes_count: u64,
    /// How many unique accounts have voted on a multiple-choice poll.
    pub voters_count: Option<u64>,
    /// When called with a user token, has the authorized user voted?
    pub voted: Option<bool>,
    /// When called with a user token, which options has the authorized user
    /// chosen? Contains an array of index values for options
    pub own_votes: Option<Vec<u64>>,
    /// Possible answers for the poll.
    pub options: Vec<PollOption>,
    /// Custom emoji to be used for rendering poll options.
    pub emojis: Vec<Emoji>,
}

/// Possible answers for the poll.
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct PollOption {
    /// The text value of the poll option.
    pub title: String,
    /// The number of received votes for this option.
    pub votes_count: Option<u64>,
}