func PostReplysCount(post *models.Post) { cnt, err := models.CountCommentsByPostId(post.Id) if err == nil { post.Replys = int(cnt) //disable post editable post.CanEdit = false err = models.UpdateById(post.Id, post, "replys", "can_edit") } if err != nil { log.Error("PostReplysCount ", err) } }
func (form *PostForm) SavePost(post *models.Post, user *models.User) error { utils.SetFormValues(form, post) post.CategoryId = form.Category post.TopicId = form.Topic post.UserId = user.Id post.LastReplyId = user.Id post.LastAuthorId = user.Id post.CanEdit = true post.ContentCache = utils.RenderMarkdown(form.Content) // mentioned follow users FilterMentions(user, post.ContentCache) return post.Insert() }