(repo ghrepo.Interface, number int32)
| 402 | } |
| 403 | |
| 404 | func (c *discussionClient) GetByNumber(repo ghrepo.Interface, number int32) (*Discussion, error) { |
| 405 | meta, err := c.getRepositoryMeta(repo) |
| 406 | if err != nil { |
| 407 | return nil, err |
| 408 | } |
| 409 | if !meta.HasDiscussionsEnabled { |
| 410 | return nil, fmt.Errorf("the '%s/%s' repository has discussions disabled", repo.RepoOwner(), repo.RepoName()) |
| 411 | } |
| 412 | |
| 413 | var query struct { |
| 414 | Repository struct { |
| 415 | Discussion struct { |
| 416 | discussionListNode |
| 417 | Comments struct { |
| 418 | TotalCount int |
| 419 | } |
| 420 | } `graphql:"discussion(number: $number)"` |
| 421 | } `graphql:"repository(owner: $owner, name: $name)"` |
| 422 | } |
| 423 | |
| 424 | variables := map[string]interface{}{ |
| 425 | "owner": githubv4.String(repo.RepoOwner()), |
| 426 | "name": githubv4.String(repo.RepoName()), |
| 427 | "number": githubv4.Int(number), |
| 428 | } |
| 429 | |
| 430 | if err := c.gql.Query(repo.RepoHost(), "DiscussionMinimal", &query, variables); err != nil { |
| 431 | return nil, err |
| 432 | } |
| 433 | |
| 434 | d := mapDiscussionFromListNode(query.Repository.Discussion.discussionListNode) |
| 435 | d.Comments = DiscussionCommentList{TotalCount: query.Repository.Discussion.Comments.TotalCount} |
| 436 | |
| 437 | for _, rg := range query.Repository.Discussion.ReactionGroups { |
| 438 | d.ReactionGroups = append(d.ReactionGroups, ReactionGroup{ |
| 439 | Content: rg.Content, |
| 440 | TotalCount: rg.Users.TotalCount, |
| 441 | }) |
| 442 | } |
| 443 | |
| 444 | return &d, nil |
| 445 | } |
| 446 | |
| 447 | // discussionReplyNode is the GraphQL response shape for a reply to a discussion comment. |
| 448 | type discussionReplyNode struct { |
nothing calls this directly
no test coverage detected