Documentation ¶
Index ¶
- Constants
- func NewPoll(creator, question string, answerOptions []string, settings Settings) (*Poll, *ErrorMessage)
- func NewSettingsFromStrings(strs []string) (Settings, *ErrorMessage)
- type AnswerOption
- type ErrorMessage
- type IDToNameConverter
- type Metadata
- type Poll
- func (p *Poll) AddAnswerOption(newAnswerOption string) *ErrorMessage
- func (p *Poll) Copy() *Poll
- func (p *Poll) EncodeToByte() []byte
- func (p *Poll) GetMetadata(userID string, permission bool) *Metadata
- func (p *Poll) GetVotedAnswers(userID string) []string
- func (p *Poll) HasVoted(userID string) bool
- func (p *Poll) IsMultiVote() bool
- func (p *Poll) ResetVotes(userID string)
- func (p *Poll) ToEndPollPost(localizer *i18n.Localizer, authorName string, convert IDToNameConverter) (*model.Post, *model.AppError)
- func (p *Poll) ToPostActions(localizer *i18n.Localizer, pluginID, authorName string) []*model.SlackAttachment
- func (p *Poll) UpdateVote(userID string, index int) (*i18n.Message, error)
- type Settings
Constants ¶
const ( SettingKeyAnonymous = "anonymous" SettingKeyProgress = "progress" SettingKeyPublicAddOption = "public-add-option" )
const (
// MatterpollAdminButtonType is action_type of buttons that are used for managing a poll.
MatterpollAdminButtonType = "custom_matterpoll_admin_button"
)
Variables ¶
This section is empty.
Functions ¶
func NewPoll ¶
func NewPoll(creator, question string, answerOptions []string, settings Settings) (*Poll, *ErrorMessage)
NewPoll creates a new poll with the given parameter.
func NewSettingsFromStrings ¶ added in v1.4.0
func NewSettingsFromStrings(strs []string) (Settings, *ErrorMessage)
NewSettingsFromStrings creates a new settings with the given parameter.
Types ¶
type AnswerOption ¶
AnswerOption stores a possible answer and a list of user who voted for this
type ErrorMessage ¶ added in v1.3.0
ErrorMessage contains error messsage for a user that can be localized. It should not be wrapped and instead always returned.
type IDToNameConverter ¶ added in v1.3.0
IDToNameConverter converts a given userID to a human readable name.
type Metadata ¶ added in v1.4.0
type Metadata struct { VotedAnswers []string `json:"voted_answers"` // VotedAnswers is list of answer that the user with "UserID" have voted for the poll with "PollID" PollID string `json:"poll_id"` UserID string `json:"user_id"` AdminPermission bool `json:"admin_permission"` // AdminPermission will be true if the user with "UserID" has admin permission for the poll with "PollID", otherwise false. SettingPublicAddOption bool `json:"setting_public_add_option"` }
Metadata stores personalized metadata of a poll.
type Poll ¶
type Poll struct { ID string PostID string `json:"post_id,omitempty"` CreatedAt int64 Creator string Question string AnswerOptions []*AnswerOption Settings Settings }
Poll stores all needed information for a poll
func DecodePollFromByte ¶
DecodePollFromByte tries to create a poll from a byte array
func (*Poll) AddAnswerOption ¶ added in v1.1.0
func (p *Poll) AddAnswerOption(newAnswerOption string) *ErrorMessage
AddAnswerOption adds a new AnswerOption to a poll
func (*Poll) EncodeToByte ¶
EncodeToByte returns a poll as a byte array
func (*Poll) GetMetadata ¶ added in v1.4.0
GetMetadata returns personalized metadata of a poll.
func (*Poll) GetVotedAnswers ¶ added in v1.4.0
GetVotedAnswers collect voted answers by a user and returns it as string array.
func (*Poll) IsMultiVote ¶ added in v1.4.0
IsMultiVote return true if poll is set to multi vote
func (*Poll) ResetVotes ¶ added in v1.4.0
ResetVotes remove votes by a given user
func (*Poll) ToEndPollPost ¶
func (p *Poll) ToEndPollPost(localizer *i18n.Localizer, authorName string, convert IDToNameConverter) (*model.Post, *model.AppError)
ToEndPollPost returns the poll end message
func (*Poll) ToPostActions ¶
func (p *Poll) ToPostActions(localizer *i18n.Localizer, pluginID, authorName string) []*model.SlackAttachment
ToPostActions returns the poll as a message
type Settings ¶ added in v1.2.0
type Settings struct { Anonymous bool Progress bool PublicAddOption bool MaxVotes int `json:"max_votes"` }
Settings stores possible settings for a poll
func NewSettingsFromSubmission ¶ added in v1.4.0
NewSettingsFromSubmission creates a new settings with the given parameter.