Exemple #1
0
func (form *CommentAdminForm) SetToComment(comment *models.Comment) {
	utils.SetFormValues(form, comment)

	comment.UserId = int64(form.User)
	comment.PostId = int64(form.Post)
	comment.MessageCache = utils.RenderMarkdown(comment.Message)
}
Exemple #2
0
func (form *CommentForm) SaveComment(comment *models.Comment, user *models.User, post *models.Post) error {
	comment.Message = form.Message
	comment.MessageCache = utils.RenderMarkdown(form.Message)
	comment.UserId = user.Id
	comment.PostId = post.Id
	if err := models.InsertComment(comment); err == nil {
		post.LastReplyId = user.Id
		models.UpdateById(post.Id, post, "last_reply_id", "last_replied")

		cnt, _ := models.CountCommentsLTEId(comment.Id)
		comment.Floor = int(cnt)
		return models.UpdateById(comment.Id, comment, "floor")
	} else {
		return err
	}
}