Documentation ¶
Index ¶
- Constants
- Variables
- func ArePollDataEquals(first, second *PollData) bool
- func RemoveDoublePosts(posts []v020posts.Post, reactions map[string][]v020posts.Reaction) ([]v020posts.Post, map[string][]v020posts.Reaction)
- func SquashPostIDs(posts []v020posts.Post, reactions map[string][]v020posts.Reaction) ([]v020posts.Post, map[string][]v020posts.Reaction)
- type AnswerID
- type GenesisState
- type OptionalData
- type PollAnswer
- type PollAnswers
- type PollData
- type Post
- type PostID
- type PostMedia
- type PostMedias
- type Reaction
- type UserAnswer
Constants ¶
const (
ModuleName = "posts"
)
Variables ¶
var (
SubspaceRegEx = regexp.MustCompile("^[a-fA-F0-9]{64}$")
)
Functions ¶
func ArePollDataEquals ¶ added in v0.4.0
ArePollDataEquals check whether the first and second pointers to a PollData object represents the same poll or not.
func RemoveDoublePosts ¶
func RemoveDoublePosts(posts []v020posts.Post, reactions map[string][]v020posts.Reaction) ([]v020posts.Post, map[string][]v020posts.Reaction)
RemoveDoublePosts removes all the duplicated posts that have the same contents from the given posts slice. All the reactions associated with the removed posts are moved to the post with the lower id.
func SquashPostIDs ¶
func SquashPostIDs(posts []v020posts.Post, reactions map[string][]v020posts.Reaction) ([]v020posts.Post, map[string][]v020posts.Reaction)
SquashPostIDs iterates over all the given posts and reactions and squashes the post IDs to be all subsequent to each other so that no IDs are skipped
Types ¶
type AnswerID ¶ added in v0.4.0
type AnswerID uint64
AnswerID represents a unique answer id
func ParseAnswerID ¶ added in v0.4.0
ParseAnswerID returns the AnswerID represented inside the provided value, or an error if no id could be parsed properly
func (AnswerID) MarshalJSON ¶ added in v0.4.0
MarshalJSON implements Marshaler
func (*AnswerID) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON implements Unmarshaler
type GenesisState ¶
type GenesisState struct { Posts []Post `json:"posts"` PollAnswers map[string][]UserAnswer `json:"poll_answers_details"` Reactions map[string][]Reaction `json:"reactions"` }
GenesisState contains the data of a v0.3.0 genesis state for the posts module
func Migrate ¶
func Migrate(oldGenState v020posts.GenesisState) GenesisState
Migrate accepts exported genesis state from v0.2.0 and migrates it to v0.3.0 genesis state. This migration changes the way subspaces are specified from a simple string to a sha-256 hash
type OptionalData ¶
type PollAnswer ¶ added in v0.4.0
type PollAnswer struct { ID AnswerID `json:"id"` // Unique id inside the post, serialized as a string for Javascript compatibility Text string `json:"text"` // Text of the answer }
PollAnswer contains the data of a single poll answer inserted by the creator
func (PollAnswer) Equals ¶ added in v0.4.0
func (pa PollAnswer) Equals(other PollAnswer) bool
Equals allows to check whether the contents of p are the same of other
type PollAnswers ¶ added in v0.4.0
type PollAnswers []PollAnswer
func (PollAnswers) Equals ¶ added in v0.4.0
func (answers PollAnswers) Equals(other PollAnswers) bool
Equals returns true iff the answers slice contains the same data in the same order of the other slice
type PollData ¶ added in v0.4.0
type PollData struct { Question string `json:"question"` // Describes what poll is about ProvidedAnswers PollAnswers `json:"provided_answers"` // Lists of answers provided by the creator EndDate time.Time `json:"end_date"` // RFC3339 date at which the poll will no longer accept new answers Open bool `json:"is_open"` // Tells if the poll is still accepting answers AllowsMultipleAnswers bool `json:"allows_multiple_answers"` // Tells if the poll is a single or multiple answers one AllowsAnswerEdits bool `json:"allows_answer_edits"` // Tells if the poll allows answer edits }
PollData contains the information of a poll that is associated to a post
type Post ¶
type Post struct { PostID PostID `json:"id"` // Unique id ParentID PostID `json:"parent_id"` // Post of which this one is a comment Message string `json:"message"` // Message contained inside the post Created time.Time `json:"created"` // RFC3339 date at which the post has been created LastEdited time.Time `json:"last_edited"` // RFC3339 date at which the post has been edited the last time AllowsComments bool `json:"allows_comments"` // Tells if users can reference this PostID as the parent Subspace string `json:"subspace"` // Identifies the application that has posted the message OptionalData OptionalData `json:"optional_data,omitempty"` // Arbitrary data that can be used from the developers Creator sdk.AccAddress `json:"creator"` // Creator of the Post Medias PostMedias `json:"medias,omitempty"` // Contains all the medias that are shared with the post PollData *PollData `json:"poll_data,omitempty"` // Contains the poll details, if existing }
Post is a struct of a post
func (Post) ConflictsWith ¶ added in v0.4.0
func (Post) ContentsEquals ¶ added in v0.4.0
ContentsEquals returns true if and only if p and other contain the same data, without considering the ID
type PostID ¶
type PostID uint64
PostID represents a unique post id
func ParsePostID ¶ added in v0.4.0
ParsePostID returns the PostID represented inside the provided value, or an error if no id could be parsed properly
func (PostID) MarshalJSON ¶ added in v0.4.0
MarshalJSON implements Marshaler
func (*PostID) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON implements Unmarshaler
type PostMedias ¶ added in v0.4.0
type PostMedias []PostMedia
func (PostMedias) Equals ¶ added in v0.4.0
func (pms PostMedias) Equals(other PostMedias) bool
Equals returns true iff the pms slice contains the same data in the same order of the other slice
type Reaction ¶
type Reaction struct { Owner sdk.AccAddress `json:"owner"` // User that has created the reaction Value string `json:"value"` // Value of the reaction }
Reaction is a struct of a user reaction to a post
type UserAnswer ¶ added in v0.4.0
type UserAnswer struct { Answers []AnswerID `json:"answers"` User sdk.AccAddress `json:"user"` }
UserAnswer contains the data of a user's answer submission to a post's poll