Repository: go-gitea/gitea
File: models/issues/comment.go (Go)

Code before:
		log.Error("LoadIssue(%d): %v", c.IssueID, err)
		return ""
	}
	err = c.Issue.LoadRepo(ctx)
	if err != nil { // Silently dropping errors :unamused:
		log.Error("loadRepo(%d): %v", c.Issue.RepoID, err)
		return ""
	}
	return fmt.Sprintf("%s/files#%s", c.Issue.Link(), c.HashTag())
}

// CreateComment creates comment with context
func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment, err error) {
	return db.WithTx2(ctx, func(ctx context.Context) (*Comment, error) {
		var LabelID int64
		if opts.Label != nil {
			LabelID = opts.Label.ID
		}

		var commentMetaData *CommentMetaData
		if opts.ProjectColumnTitle != "" || opts.IsCodeOwnersReviewRequest {
			commentMetaData = &CommentMetaData{
				ProjectColumnID:           opts.ProjectColumnID,
				ProjectColumnTitle:        opts.ProjectColumnTitle,
				ProjectTitle:              opts.ProjectTitle,
				IsCodeOwnersReviewRequest: opts.IsCodeOwnersReviewRequest,
			}
		}

		comment := &Comment{
			Type:             opts.Type,
			PosterID:         opts.Doer.ID,
			Poster:           opts.Doer,
			IssueID:          opts.Issue.ID,
			LabelID:          LabelID,
			OldMilestoneID:   opts.OldMilestoneID,
			MilestoneID:      opts.MilestoneID,
			OldProjectID:     opts.OldProjectID,
			ProjectID:        opts.ProjectID,
			TimeID:           opts.TimeID,
			RemovedAssignee:  opts.RemovedAssignee,
			AssigneeID:       opts.AssigneeID,
			AssigneeTeamID:   opts.AssigneeTeamID,
			CommitID:         opts.CommitID,
			CommitSHA:        opts.CommitSHA,
			Line:             opts.LineNum,
			Content:          opts.Content,
			OldTitle:         opts.OldTitle,
			NewTitle:         opts.NewTitle,
			OldRef:           opts.OldRef,
			NewRef:           opts.NewRef,

Review comment (suggestion):
Ideally:

```
if opts.ProjectColumnTitle != "" {
    commentMetaData = &CommentMetaData{ project fields }
}
if opts.IsCodeOwnersReviewRequest {
    commentMetaData = &CommentMetaData{ code owners review fields }
}
```


Code after:
}

// CodeCommentLink returns the url to a comment in code
func (c *Comment) CodeCommentLink(ctx context.Context) string {
	err := c.LoadIssue(ctx)
	if err != nil { // Silently dropping errors :unamused:
		log.Error("LoadIssue(%d): %v", c.IssueID, err)
		return ""
	}
	err = c.Issue.LoadRepo(ctx)
	if err != nil { // Silently dropping errors :unamused:
		log.Error("loadRepo(%d): %v", c.Issue.RepoID, err)
		return ""
	}
	return fmt.Sprintf("%s/files#%s", c.Issue.Link(), c.HashTag())
}

func (c *Comment) MetaSpecialDoerTr(locale translation.Locale) template.HTML {
	if c.CommentMetaData == nil {
		return ""
	}
	if c.CommentMetaData.SpecialDoerName == SpecialDoerNameCodeOwners {
		return locale.Tr("repo.issues.review.codeowners_rules")
	}
	return htmlutil.HTMLFormat("%s", c.CommentMetaData.SpecialDoerName)
}

func (c *Comment) TimelineRequestedReviewTr(locale translation.Locale, createdStr template.HTML) template.HTML {
	if c.AssigneeID > 0 {
		// it guarantees LoadAssigneeUserAndTeam has been called, and c.Assignee is Ghost user but not nil if the user doesn't exist
		if c.RemovedAssignee {
			if c.PosterID == c.AssigneeID {
				return locale.Tr("repo.issues.review.remove_review_request_self", createdStr)
			}
			return locale.Tr("repo.issues.review.remove_review_request", c.Assignee.GetDisplayName(), createdStr)
		}
		return locale.Tr("repo.issues.review.add_review_request", c.Assignee.GetDisplayName(), createdStr)
	}
	teamName := "Ghost Team"
	if c.AssigneeTeam != nil {
		teamName = c.AssigneeTeam.Name
	}
	if c.RemovedAssignee {
		return locale.Tr("repo.issues.review.remove_review_request", teamName, createdStr)
	}
	return locale.Tr("repo.issues.review.add_review_request", teamName, createdStr)
}

// CreateComment creates comment with context
func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment, err error) {
	return db.WithTx2(ctx, func(ctx context.Context) (*Comment, error) {