Documentation ¶
Index ¶
Constants ¶
const ListDBName = "comments/mailing-list"
ListDBName is the path to the singleton mailing list manager.
Variables ¶
var DB *jsondb.DB
DB is a reference to the parent app's JsonDB object.
Functions ¶
This section is empty.
Types ¶
type Comment ¶
type Comment struct { ID string `json:"id"` UserID int `json:"userId,omitempty"` Name string `json:"name,omitempty"` Email string `json:"email,omitempty"` Avatar string `json:"avatar"` Body string `json:"body"` EditToken string `json:"editToken"` DeleteToken string `json:"deleteToken"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` // Private form use only. CSRF string `json:"-"` Subscribe bool `json:"-"` ThreadID string `json:"-"` OriginURL string `json:"-"` Subject string `json:"-"` HTML template.HTML `json:"-"` Trap1 string `json:"-"` Trap2 string `json:"-"` // Even privater fields. IsAuthenticated bool `json:"-"` Username string `json:"-"` Editable bool `json:"-"` Editing bool `json:"-"` }
Comment contains the data for a single comment in a thread.
func (*Comment) LoadAvatar ¶
func (c *Comment) LoadAvatar()
LoadAvatar calculates the user's avatar for the comment.
type MailingList ¶
type MailingList struct {
Threads map[string]Subscription
}
MailingList manages subscription data for all comment threads.
func LoadMailingList ¶
func LoadMailingList() *MailingList
LoadMailingList loads the mailing list, or initializes it if it doesn't exist.
func (*MailingList) List ¶
func (m *MailingList) List(thread string) []string
List the subscribers for a thread.
func (*MailingList) Subscribe ¶
func (m *MailingList) Subscribe(thread, email string) error
Subscribe to a comment thread.
func (*MailingList) Unsubscribe ¶
func (m *MailingList) Unsubscribe(thread, email string) bool
Unsubscribe from a comment thread. Returns true if the removal was successful; false indicates the email was not subscribed.
func (*MailingList) UnsubscribeAll ¶
func (m *MailingList) UnsubscribeAll(email string) bool
UnsubscribeAll removes the email from all mailing lists.
type Subscription ¶
Subscription is the data for a single thread's subscribers.
type Thread ¶
Thread contains a thread of comments, for a blog post or otherwise.
func (*Thread) FindByDeleteToken ¶
FindByDeleteToken finds a comment by its deletion token.