// NewPostComment handles the request and creates a new post
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)
	}
}
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)
		}
	}
}
430624
func (c *jiraClientImpl) PostComment(issueID string, commentToPost string) error {
	_, _, err := c.Client.Issue.AddComment(issueID, &jira.Comment{Body: commentToPost})
	return err
}
638509
func newCommentToken(b []rune) (Token, int, error) {
	i := 0
	for ; i < len(b); i++ {
		if b[i] == '\n' {
			break
		}

		if len(b)-i > 2 && b[i] == '\r' && b[i+1] == '\n' {
			break
		}
	}

	return newToken(TokenComment, b[:i], NoneType), i, nil
}
73874
func (s *RepositoriesService) CreateComment(ctx context.Context, owner, repo, sha string, comment *RepositoryComment) (*RepositoryComment, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/commits/%v/comments", owner, repo, sha)
	req, err := s.client.NewRequest("POST", u, comment)
	if err != nil {
		return nil, nil, err
	}

	c := new(RepositoryComment)
	resp, err := s.client.Do(ctx, req, c)
	if err != nil {
		return nil, resp, err
	}

	return c, resp, nil
}
537818
func (comment *UserPostComment) Post() (ExistingPost, error) {
	var post *UserPost
	var err error
	if post, err = NewUserPost(comment.Hpid); err != nil {
		return nil, err
	}
	return ExistingPost(post), nil
}
1217400
func NewPaperDocEditCommentType(Description string) *PaperDocEditCommentType {
	s := new(PaperDocEditCommentType)
	s.Description = Description
	return s
}
244776
func NewPostDec(Variable node.Node) *PostDec {
	return &PostDec{
		FreeFloating: nil,
		Variable:     Variable,
	}
}
431068
func NewPostMessageParameters() PostMessageParameters {
	return PostMessageParameters{
		Username:        DEFAULT_MESSAGE_USERNAME,
		User:            DEFAULT_MESSAGE_USERNAME,
		AsUser:          DEFAULT_MESSAGE_ASUSER,
		Parse:           DEFAULT_MESSAGE_PARSE,
		ThreadTimestamp: DEFAULT_MESSAGE_THREAD_TIMESTAMP,
		LinkNames:       DEFAULT_MESSAGE_LINK_NAMES,
		UnfurlLinks:     DEFAULT_MESSAGE_UNFURL_LINKS,
		UnfurlMedia:     DEFAULT_MESSAGE_UNFURL_MEDIA,
		IconURL:         DEFAULT_MESSAGE_ICON_URL,
		IconEmoji:       DEFAULT_MESSAGE_ICON_EMOJI,
		Markdown:        DEFAULT_MESSAGE_MARKDOWN,
		EscapeText:      DEFAULT_MESSAGE_ESCAPE_TEXT,
	}
}
1104549
func (o *OAuthSession) SubredditComments(subreddit string) ([]*Comment, error) {
	baseURL := "https://www.reddit.com"

	if subreddit != "" {
		baseURL += "/r/" + subreddit
	}

	subCommentsURL := baseURL + "/comments.json"

	req := request{
		url:       subCommentsURL,
		useragent: o.UserAgent,
	}

	body, err := req.getResponse()
	if err != nil {
		return nil, err
	}

	var comments interface{}
	if err = json.NewDecoder(body).Decode(&comments); err != nil {
		return nil, err
	}

	helper := new(helper)
	helper.buildComments(comments)
	return helper.comments, nil
}
61192
func PostComments() echo.HandlerFunc {

	// swagger:route GET /me/posts/{pid}/comments me post comments GetMePostComments
	//
	// List comments on specified post, filtered by some parameters.
	//
	// This will show the last posts on the user board by default.
	// You can personalize the request via query string parameters
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile_comments:read
	//
	//	Responses:
	//		default: MePostsPidComments

	return func(c echo.Context) error {
		return user.PostComments()(c)
	}
}
1155786
func NewCommentCreated(commentID string) Message {
	return Message{MessageID: uuid.NewV4(), MessageType: "comment.create", TargetID: commentID}
}
636794
func (m *GormCommentRepository) Create(ctx context.Context, comment *Comment, creatorID uuid.UUID) error {
	defer goa.MeasureSince([]string{"goa", "db", "comment", "create"}, time.Now())
	comment.ID = uuid.NewV4()
	// make sure no comment is created with an empty 'markup' value
	if comment.Markup == "" {
		comment.Markup = rendering.SystemMarkupDefault
	}
	if err := m.db.Create(comment).Error; err != nil {
		log.Error(ctx, map[string]interface{}{
			"comment_id": comment.ID,
			"err":        err,
		}, "unable to create the comment")
		return errs.WithStack(err)
	}
	// save a revision of the created comment
	if err := m.revisionRepository.Create(ctx, creatorID, RevisionTypeCreate, *comment); err != nil {
		return errs.Wrapf(err, "error while creating comment")
	}
	log.Debug(ctx, map[string]interface{}{
		"comment_id": comment.ID,
	}, "Comment created!")

	return nil
}
474753
func (c oauthClient) CreateTaskComment(text string, taskID uint) (wl.TaskComment, error) {
	if taskID == 0 {
		return wl.TaskComment{}, errors.New("taskID must be > 0")
	}

	body := []byte(fmt.Sprintf(`{"text":"%s","task_id":%d}`, text, taskID))

	url := fmt.Sprintf("%s/task_comments", c.apiURL)

	req, err := c.newPostRequest(url, body)
	if err != nil {
		return wl.TaskComment{}, err
	}

	resp, err := c.do(req)
	if err != nil {
		return wl.TaskComment{}, err
	}

	if resp.StatusCode != http.StatusCreated {
		return wl.TaskComment{}, fmt.Errorf("Unexpected response code %d - expected %d", resp.StatusCode, http.StatusCreated)
	}

	taskComment := wl.TaskComment{}
	err = json.NewDecoder(resp.Body).Decode(&taskComment)
	if err != nil {
		return wl.TaskComment{}, err
	}
	return taskComment, nil
}
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)
	}
}
1329740
func NewPostRoute(path string, handler httputils.APIFunc, opts ...RouteWrapper) Route {
	return NewRoute("POST", path, handler, opts...)
}
847354
func NewPostVote() echo.HandlerFunc {

	// swagger:route POST /users/{id}/posts/{pid}/votes users post vote NewUserPostVote
	//
	// Adds a new vote on the current post
	//
	// Consumes:
	// - application/json
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile_messages:write
	//
	//	Responses:
	//		default: UsersIdPostsPidVotes

	return func(c echo.Context) error {
		if !rest.IsGranted("profile_messages:write", c) {
			return rest.InvalidScopeResponse("profile_messages:write", c)
		}

		// Read a rest.NewVote from the body request.
		body := rest.NewVote{}
		if err := c.Bind(&body); err != nil {
			errstr := err.Error()
			c.JSON(http.StatusBadRequest, &rest.Response{
				Data:         nil,
				HumanMessage: errstr,
				Message:      errstr,
				Status:       http.StatusBadRequest,
				Success:      false,
			})
			return errors.New(errstr)
		}

		// Send it
		me := c.Get("me").(*nerdz.User)
		post := c.Get("post").(*nerdz.UserPost)
		vote, err := me.Vote(post, body.Vote)
		if err != nil {
			errstr := err.Error()
			c.JSON(http.StatusBadRequest, &rest.Response{
				Data:         nil,
				HumanMessage: errstr,
				Message:      errstr,
				Status:       http.StatusBadRequest,
				Success:      false,
			})
			return errors.New(errstr)
		}
		// Extract the TO from the new post and return
		// selected fields.
		return rest.SelectFields(vote.(*nerdz.UserPostVote).GetTO(me), c)
	}
}