poll

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnswerOption

type AnswerOption struct {
	Answer string
	Voter  []string
}

AnswerOption stores a possible answer and a list of user who voted for this

type Poll

type Poll struct {
	ID            string
	CreatedAt     int64
	Creator       string
	Question      string
	AnswerOptions []*AnswerOption
	Settings      PollSettings
}

Poll stores all needed information for a poll

func DecodePollFromByte

func DecodePollFromByte(b []byte) *Poll

DecodePollFromByte tries to create a poll from a byte array

func NewPoll

func NewPoll(creator, question string, answerOptions, settings []string) (*Poll, error)

NewPoll creates a new poll with the given paramatern

func (*Poll) Copy

func (p *Poll) Copy() *Poll

Copy deep copys a poll

func (*Poll) EncodeToByte

func (p *Poll) EncodeToByte() []byte

EncodeToByte returns a poll as a byte array

func (*Poll) HasVoted

func (p *Poll) HasVoted(userID string) bool

HasVoted return true if a given user has voted in this poll

func (*Poll) ToEndPollPost

func (p *Poll) ToEndPollPost(authorName string, convert func(string) (string, *model.AppError)) (*model.Post, *model.AppError)

ToEndPollPost returns the poll end message

func (*Poll) ToPostActions

func (p *Poll) ToPostActions(siteURL, pluginID, authorName string) []*model.SlackAttachment

ToPostActions returns the poll as a message

func (*Poll) UpdateVote

func (p *Poll) UpdateVote(userID string, index int) error

UpdateVote performs a vote for a given user

type PollSettings

type PollSettings struct {
	Anonymous bool
	Progress  bool
}

PollSettings stores possible settings for a poll

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL