Documentation ¶
Index ¶
- Constants
- Variables
- type DataStore
- func (s *DataStore) Counts(siteID string, postIDs []string) ([]store.PostInfo, error)
- func (s *DataStore) Create(comment store.Comment) (commentID string, err error)
- func (s *DataStore) EditComment(locator store.Locator, commentID string, req EditRequest) (comment store.Comment, err error)
- func (s *DataStore) HasReplies(comment store.Comment) bool
- func (s *DataStore) IsAdmin(siteID string, userID string) bool
- func (s *DataStore) Metas(siteID string) (umetas []UserMetaData, pmetas []PostMetaData, err error)
- func (s *DataStore) SetMetas(siteID string, umetas []UserMetaData, pmetas []PostMetaData) (err error)
- func (s *DataStore) SetPin(locator store.Locator, commentID string, status bool) error
- func (s *DataStore) SetTitle(locator store.Locator, commentID string) (comment store.Comment, err error)
- func (s *DataStore) ValidateComment(c *store.Comment) error
- func (s *DataStore) Vote(locator store.Locator, commentID string, userID string, val bool) (comment store.Comment, err error)
- type EditRequest
- type PostMetaData
- type RestrictedWordsLister
- type RestrictedWordsMatcher
- type StaticRestrictedWordsLister
- type TitleExtractor
- type UserMetaData
Constants ¶
const UnlimitedVotes = -1
UnlimitedVotes doesn't restrict MaxVotes
Variables ¶
var ErrRestrictedWordsFound = errors.New("comment contains restricted words")
ErrRestrictedWordsFound returned in case comment text contains restricted words
Functions ¶
This section is empty.
Types ¶
type DataStore ¶
type DataStore struct { engine.Interface EditDuration time.Duration AdminStore admin.Store MaxCommentSize int MaxVotes int TitleExtractor *TitleExtractor RestrictedWordsMatcher *RestrictedWordsMatcher // contains filtered or unexported fields }
DataStore wraps store.Interface with additional methods
func (*DataStore) EditComment ¶
func (s *DataStore) EditComment(locator store.Locator, commentID string, req EditRequest) (comment store.Comment, err error)
EditComment to edit text and update Edit info
func (*DataStore) HasReplies ¶ added in v1.2.0
HasReplies checks if there is any reply to the comments Loads last maxLastCommentsReply comments and compare parent id to the comment's id Comments with replies cached for 5 minutes
func (*DataStore) Metas ¶
func (s *DataStore) Metas(siteID string) (umetas []UserMetaData, pmetas []PostMetaData, err error)
Metas returns metadata for users and posts
func (*DataStore) SetMetas ¶
func (s *DataStore) SetMetas(siteID string, umetas []UserMetaData, pmetas []PostMetaData) (err error)
SetMetas saves metadata for users and posts
func (*DataStore) SetTitle ¶
func (s *DataStore) SetTitle(locator store.Locator, commentID string) (comment store.Comment, err error)
SetTitle puts title from the locator.URL page and overwrites any existing title
func (*DataStore) ValidateComment ¶
ValidateComment checks if comment size below max and user fields set
type EditRequest ¶
EditRequest contains fields needed for comment update
type PostMetaData ¶
PostMetaData keeps info about post flags
type RestrictedWordsLister ¶ added in v1.2.0
RestrictedWordsLister provides restricted words in comments per site
type RestrictedWordsMatcher ¶ added in v1.2.0
type RestrictedWordsMatcher struct {
// contains filtered or unexported fields
}
RestrictedWordsMatcher matches comment text against restricted words
func NewRestrictedWordsMatcher ¶ added in v1.2.0
func NewRestrictedWordsMatcher(lister RestrictedWordsLister) *RestrictedWordsMatcher
NewRestrictedWordsMatcher creates new RestrictedWordsMatcher using provided RestrictedWordsLister
type StaticRestrictedWordsLister ¶ added in v1.2.0
type StaticRestrictedWordsLister struct {
Words []string
}
StaticRestrictedWordsLister provides same restricted words in comments for every site
type TitleExtractor ¶
type TitleExtractor struct {
// contains filtered or unexported fields
}
TitleExtractor gets html title from remote page, cached
func NewTitleExtractor ¶
func NewTitleExtractor(client http.Client) *TitleExtractor
NewTitleExtractor makes extractor with cache. If memory cache failed, switching to no-cache