mapCommentFromNode converts a discussionCommentNode into the domain DiscussionComment type.
(n discussionCommentNode)
| 502 | |
| 503 | // mapCommentFromNode converts a discussionCommentNode into the domain DiscussionComment type. |
| 504 | func mapCommentFromNode(n discussionCommentNode) DiscussionComment { |
| 505 | dc := DiscussionComment{ |
| 506 | ID: n.ID, |
| 507 | URL: n.URL, |
| 508 | Author: mapActorFromListNode(n.Author), |
| 509 | Body: n.Body, |
| 510 | CreatedAt: n.CreatedAt, |
| 511 | IsAnswer: n.IsAnswer, |
| 512 | UpvoteCount: n.UpvoteCount, |
| 513 | } |
| 514 | |
| 515 | for _, rg := range n.ReactionGroups { |
| 516 | dc.ReactionGroups = append(dc.ReactionGroups, ReactionGroup{ |
| 517 | Content: rg.Content, |
| 518 | TotalCount: rg.Users.TotalCount, |
| 519 | }) |
| 520 | } |
| 521 | |
| 522 | replyComments := make([]DiscussionComment, len(n.Replies.Nodes)) |
| 523 | for i, r := range n.Replies.Nodes { |
| 524 | replyComments[i] = mapReplyFromNode(r) |
| 525 | } |
| 526 | dc.Replies = DiscussionCommentList{ |
| 527 | Comments: replyComments, |
| 528 | TotalCount: n.Replies.TotalCount, |
| 529 | Direction: DiscussionCommentListDirectionBackward, |
| 530 | } |
| 531 | |
| 532 | return dc |
| 533 | } |
| 534 | |
| 535 | func (c *discussionClient) GetWithComments(repo ghrepo.Interface, number int32, limit int, after string, newest bool) (*Discussion, error) { |
| 536 | meta, err := c.getRepositoryMeta(repo) |
no test coverage detected