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