// DeletePostComment handles the request and deletes the comment
350140
func DeletePostComment() echo.HandlerFunc {

	// swagger:route DELETE /me/posts/{pid}/comments/{cid} me post DeleteMePostComment
	//
	// Delete the specified comment on the speficied user post
	//
	// Consumes:
	// - application/json
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile_comments:write
	//
	//	Responses:
	//		default: apiResponse

	return func(c echo.Context) error {
		return user.DeletePostComment()(c)
	}
}
1151357
func (c *Comments) AddComment(comment *Comment) {
	if c.primary {
		if !c.wasLineBreak {
			c.Comments = append(c.Comments, comment)
		} else {
			c.future = append(c.future, comment)
		}
	} else {
		if !c.wasLineBreak || (c.Current == nil && !c.afterBlock) {
			c.Comments = append(c.Comments, comment)
		} else {
			c.future = append(c.future, comment)
		}
	}
}
1039716
func (s *CreateTrafficPolicyVersionInput) SetComment(v string) *CreateTrafficPolicyVersionInput {
	s.Comment = &v
	return s
}
459609
func DeletePost(client ClientInterface, name string, postId uint64) error {
	_, err := client.PostWithParams(blogPath("/blog/%s/post/delete", name), setPostId(postId, url.Values{}))
	return err
}
1352611
func parseComment(t *thing) (*Comment, error) {
	// Reddit makes the replies field a string if it is empty, just to make
	// it harder for programmers who like static type systems.
	value, present := t.Data["replies"]
	if present {
		if str, ok := value.(string); ok && str == "" {
			delete(t.Data, "replies")
		}
	}

	c := &comment{}
	if err := mapstructure.Decode(t.Data, c); err != nil {
		return nil, mapDecodeError(err, t.Data)
	}

	var err error
	if c.Replies.Kind == listingKind {
		c.Comment.Replies, _, _, err = parseListing(&c.Replies)
	}

	c.Comment.Deleted = c.Comment.Body == deletedKey
	return &c.Comment, err
}
345510
func (f *File) RemoveJSONComments() {
	if f.Mode == "json" {
		// remove inline comments
		f.Data = []byte(regexComments.ReplaceAllString(string(f.Data), ""))
	}
}
1361033
func (c *Client) DeleteIssueComment(owner, repo string, index, commentID int64) error {
	_, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/comments/%d", owner, repo, index, commentID), nil, nil)
	return err
}
547105
func (comments *Comments) Del(comment *Comment) error {
	insta := comments.item.media.instagram()

	data, err := insta.prepareData()
	if err != nil {
		return err
	}
	id := comment.getid()

	_, err = insta.sendRequest(
		&reqOptions{
			Endpoint: fmt.Sprintf(urlCommentDelete, comments.item.ID, id),
			Query:    generateSignature(data),
			IsPost:   true,
		},
	)
	return err
}
60566
func (o *OAuthSession) SavedComments(user string, params ListingOptions) ([]*Comment, error) {
	var s interface{}
	url := fmt.Sprintf("https://oauth.reddit.com/user/%s/saved", user)
	err := o.getBody(url, &s)
	if err != nil {
		return nil, err
	}

	helper := new(helper)
	helper.buildComments(s)
	return helper.comments, nil
}
104549
func (user *User) CanComment(message ExistingPost) bool {
	return !utils.InSlice(user.ID(), message.Sender().NumericBlacklist()) && message.ID() > 0 && !message.IsClosed()
}
986430
func SetComment() echo.MiddlewareFunc {
	return func(next echo.HandlerFunc) echo.HandlerFunc {
		return echo.HandlerFunc(func(c echo.Context) error {

			var cid uint64
			var e error
			if cid, e = strconv.ParseUint(c.Param("cid"), 10, 64); e != nil {
				c.JSON(http.StatusBadRequest, &rest.Response{
					HumanMessage: "Invalid comment identifier specified",
					Message:      e.Error(),
					Status:       http.StatusBadRequest,
					Success:      false,
				})
				return e
			}

			var comment *nerdz.ProjectPostComment
			if comment, e = nerdz.NewProjectPostComment(cid); e != nil {
				c.JSON(http.StatusBadRequest, &rest.Response{
					HumanMessage: "Invalid comment identifier specified",
					Message:      e.Error(),
					Status:       http.StatusBadRequest,
					Success:      false,
				})
				return e
			}

			post := c.Get("post").(*nerdz.ProjectPost)
			if comment.Hpid != post.Hpid {
				errstr := "Mismatch between comment ID and post ID. Comment not related to the post"
				c.JSON(http.StatusBadRequest, &rest.Response{
					HumanMessage: errstr,
					Message:      errstr,
					Status:       http.StatusBadRequest,
					Success:      false,
				})
				return errors.New(errstr)
			}
			c.Set("comment", comment)
			return next(c)
		})
	}
}
247859
func DeleteCommentByID(doer *User, id int64) error {
	comment, err := GetCommentByID(id)
	if err != nil {
		if IsErrCommentNotExist(err) {
			return nil
		}
		return err
	}

	sess := x.NewSession()
	defer sess.Close()
	if err = sess.Begin(); err != nil {
		return err
	}

	if _, err = sess.ID(comment.ID).Delete(new(Comment)); err != nil {
		return err
	}

	if comment.Type == COMMENT_TYPE_COMMENT {
		if _, err = sess.Exec("UPDATE `issue` SET num_comments = num_comments - 1 WHERE id = ?", comment.IssueID); err != nil {
			return err
		}
	}

	if err = sess.Commit(); err != nil {
		return fmt.Errorf("commit: %v", err)
	}

	_, err = DeleteAttachmentsByComment(comment.ID, true)
	if err != nil {
		log.Error(2, "Failed to delete attachments by comment[%d]: %v", comment.ID, err)
	}

	if err = comment.Issue.LoadAttributes(); err != nil {
		log.Error(2, "Issue.LoadAttributes [issue_id: %d]: %v", comment.IssueID, err)
	} else if err = PrepareWebhooks(comment.Issue.Repo, HOOK_EVENT_ISSUE_COMMENT, &api.IssueCommentPayload{
		Action:     api.HOOK_ISSUE_COMMENT_DELETED,
		Issue:      comment.Issue.APIFormat(),
		Comment:    comment.APIFormat(),
		Repository: comment.Issue.Repo.APIFormat(nil),
		Sender:     doer.APIFormat(),
	}); err != nil {
		log.Error(2, "PrepareWebhooks [comment_id: %d]: %v", comment.ID, err)
	}
	return nil
}
894697
func (c *Card) AddComment(text string) (*Action, error) {
	newAction := &Action{}

	payload := url.Values{}
	payload.Set("text", text)

	body, err := c.client.Post("/cards/"+c.Id+"/actions/comments", payload)
	if err != nil {
		return nil, err
	}
	if err = json.Unmarshal(body, newAction); err != nil {
		return nil, err
	}
	newAction.client = c.client
	return newAction, nil
}
112459
func UpdateComment(doer *User, c *Comment, oldContent string) (err error) {
	if _, err = x.Id(c.ID).AllCols().Update(c); err != nil {
		return err
	}

	if err = c.Issue.LoadAttributes(); err != nil {
		log.Error(2, "Issue.LoadAttributes [issue_id: %d]: %v", c.IssueID, err)
	} else if err = PrepareWebhooks(c.Issue.Repo, HOOK_EVENT_ISSUE_COMMENT, &api.IssueCommentPayload{
		Action:  api.HOOK_ISSUE_COMMENT_EDITED,
		Issue:   c.Issue.APIFormat(),
		Comment: c.APIFormat(),
		Changes: &api.ChangesPayload{
			Body: &api.ChangesFromPayload{
				From: oldContent,
			},
		},
		Repository: c.Issue.Repo.APIFormat(nil),
		Sender:     doer.APIFormat(),
	}); err != nil {
		log.Error(2, "PrepareWebhooks [comment_id: %d]: %v", c.ID, err)
	}

	return nil
}
1241243
func (s *DeleteCommentContentOutput) SetComment(v *Comment) *DeleteCommentContentOutput {
	s.Comment = v
	return s
}
278280
func (c *Commit) GetCommentCount() int {
	if c == nil || c.CommentCount == nil {
		return 0
	}
	return *c.CommentCount
}
354207
func NewPostComment() echo.HandlerFunc {

	// swagger:route POST /me/posts/{pid}/comments me post NewMePostComment
	//
	// Creates a new post on the specified user board
	//
	// Consumes:
	// - application/json
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile_comments:write
	//
	//	Responses:
	//		default: MePostsPidCommentsCid

	return func(c echo.Context) error {
		return user.NewPostComment()(c)
	}
}