|
8 | 8 |
|
9 | 9 | "github.com/github/github-mcp-server/pkg/ifc" |
10 | 10 | "github.com/github/github-mcp-server/pkg/inventory" |
| 11 | + "github.com/github/github-mcp-server/pkg/sanitize" |
11 | 12 | "github.com/github/github-mcp-server/pkg/scopes" |
12 | 13 | "github.com/github/github-mcp-server/pkg/translations" |
13 | 14 | "github.com/github/github-mcp-server/pkg/utils" |
@@ -99,7 +100,7 @@ type WithCategoryNoOrder struct { |
99 | 100 | func fragmentToDiscussion(fragment NodeFragment) *github.Discussion { |
100 | 101 | return &github.Discussion{ |
101 | 102 | Number: github.Ptr(int(fragment.Number)), |
102 | | - Title: github.Ptr(string(fragment.Title)), |
| 103 | + Title: github.Ptr(sanitize.Sanitize(string(fragment.Title))), |
103 | 104 | HTMLURL: github.Ptr(string(fragment.URL)), |
104 | 105 | CreatedAt: &github.Timestamp{Time: fragment.CreatedAt.Time}, |
105 | 106 | UpdatedAt: &github.Timestamp{Time: fragment.UpdatedAt.Time}, |
@@ -360,8 +361,8 @@ func GetDiscussion(t translations.TranslationHelperFunc) inventory.ServerTool { |
360 | 361 | // like ListDiscussions and GetDiscussionComments). |
361 | 362 | response := map[string]any{ |
362 | 363 | "number": int(d.Number), |
363 | | - "title": string(d.Title), |
364 | | - "body": string(d.Body), |
| 364 | + "title": sanitize.Sanitize(string(d.Title)), |
| 365 | + "body": sanitize.Sanitize(string(d.Body)), |
365 | 366 | "url": string(d.URL), |
366 | 367 | "closed": bool(d.Closed), |
367 | 368 | "isAnswered": bool(d.IsAnswered), |
@@ -520,18 +521,10 @@ func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.Serve |
520 | 521 | return utils.NewToolResultError(err.Error()), nil, nil |
521 | 522 | } |
522 | 523 | for _, c := range q.Repository.Discussion.Comments.Nodes { |
523 | | - comment := MinimalDiscussionComment{ |
524 | | - ID: fmt.Sprintf("%v", c.ID), |
525 | | - Body: string(c.Body), |
526 | | - IsAnswer: bool(c.IsAnswer), |
527 | | - ReplyTotalCount: c.Replies.TotalCount, |
528 | | - } |
| 524 | + comment := newMinimalDiscussionComment(fmt.Sprintf("%v", c.ID), string(c.Body), bool(c.IsAnswer)) |
| 525 | + comment.ReplyTotalCount = c.Replies.TotalCount |
529 | 526 | for _, r := range c.Replies.Nodes { |
530 | | - comment.Replies = append(comment.Replies, MinimalDiscussionComment{ |
531 | | - ID: fmt.Sprintf("%v", r.ID), |
532 | | - Body: string(r.Body), |
533 | | - IsAnswer: bool(r.IsAnswer), |
534 | | - }) |
| 527 | + comment.Replies = append(comment.Replies, newMinimalDiscussionComment(fmt.Sprintf("%v", r.ID), string(r.Body), bool(r.IsAnswer))) |
535 | 528 | } |
536 | 529 | comments = append(comments, comment) |
537 | 530 | } |
@@ -562,11 +555,7 @@ func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.Serve |
562 | 555 | return utils.NewToolResultError(err.Error()), nil, nil |
563 | 556 | } |
564 | 557 | for _, c := range q.Repository.Discussion.Comments.Nodes { |
565 | | - comments = append(comments, MinimalDiscussionComment{ |
566 | | - ID: fmt.Sprintf("%v", c.ID), |
567 | | - Body: string(c.Body), |
568 | | - IsAnswer: bool(c.IsAnswer), |
569 | | - }) |
| 558 | + comments = append(comments, newMinimalDiscussionComment(fmt.Sprintf("%v", c.ID), string(c.Body), bool(c.IsAnswer))) |
570 | 559 | } |
571 | 560 | pageInfo = q.Repository.Discussion.Comments.PageInfo |
572 | 561 | totalCount = q.Repository.Discussion.Comments.TotalCount |
|
0 commit comments