minor renaming
This commit is contained in:
@@ -134,7 +134,7 @@ func (s *Rest) createCommentCtrl(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
comment.Init()
|
||||
comment.Prepare() // clean all fields user not suppoed to set
|
||||
comment.User = user
|
||||
comment.User.IP = strings.Split(r.RemoteAddr, ":")[0]
|
||||
comment.Text = string(blackfriday.Run([]byte(comment.Text), blackfriday.WithNoExtensions())) // render markdown
|
||||
|
||||
+3
-12
@@ -58,8 +58,9 @@ type BlockedUser struct {
|
||||
Timestamp time.Time `json:"time"`
|
||||
}
|
||||
|
||||
// Init comment skeleton
|
||||
func (c *Comment) Init() {
|
||||
// Prepare comment received from untrusted source by clearing all autogen fields and
|
||||
// reset everyting users not supposed to provide
|
||||
func (c *Comment) Prepare() {
|
||||
c.ID = "" // don't allow user to define ID, force auto-gen
|
||||
c.Timestamp = time.Time{} // reset time, force auto-gen
|
||||
c.Votes = make(map[string]bool)
|
||||
@@ -95,13 +96,3 @@ type NotifUser struct {
|
||||
ID string `json:"id"`
|
||||
Destination string `json:"destination"`
|
||||
}
|
||||
|
||||
// NotifScope defines "enum" of notification scopes
|
||||
type NotifScope int
|
||||
|
||||
// All NotifScope values
|
||||
const (
|
||||
ScopeSite NotifScope = 1
|
||||
ScopePost NotifScope = 2
|
||||
ScopeReply NotifScope = 3
|
||||
)
|
||||
|
||||
@@ -30,6 +30,9 @@ func (s *Service) Vote(locator Locator, commentID string, userID string, val boo
|
||||
return comment, err
|
||||
}
|
||||
|
||||
if comment.Votes == nil {
|
||||
comment.Votes = make(map[string]bool)
|
||||
}
|
||||
v, voted := comment.Votes[userID]
|
||||
|
||||
if voted && v == val {
|
||||
|
||||
Reference in New Issue
Block a user