UpdateComment updates the body of an existing discussion comment or reply.
(repo ghrepo.Interface, commentID, body string)
| 1157 | |
| 1158 | // UpdateComment updates the body of an existing discussion comment or reply. |
| 1159 | func (c *discussionClient) UpdateComment(repo ghrepo.Interface, commentID, body string) (*DiscussionComment, error) { |
| 1160 | var mutation struct { |
| 1161 | UpdateDiscussionComment struct { |
| 1162 | Comment struct { |
| 1163 | ID string |
| 1164 | URL string `graphql:"url"` |
| 1165 | Author actorNode |
| 1166 | Body string |
| 1167 | CreatedAt time.Time |
| 1168 | IsAnswer bool |
| 1169 | UpvoteCount int |
| 1170 | ReactionGroups []struct { |
| 1171 | Content string |
| 1172 | Users struct { |
| 1173 | TotalCount int |
| 1174 | } |
| 1175 | } `graphql:"reactionGroups"` |
| 1176 | } |
| 1177 | } `graphql:"updateDiscussionComment(input: $input)"` |
| 1178 | } |
| 1179 | |
| 1180 | variables := map[string]any{ |
| 1181 | "input": githubv4.UpdateDiscussionCommentInput{ |
| 1182 | CommentID: githubv4.ID(commentID), |
| 1183 | Body: githubv4.String(body), |
| 1184 | }, |
| 1185 | } |
| 1186 | |
| 1187 | if err := c.gql.Mutate(repo.RepoHost(), "UpdateDiscussionComment", &mutation, variables); err != nil { |
| 1188 | return nil, err |
| 1189 | } |
| 1190 | |
| 1191 | src := mutation.UpdateDiscussionComment.Comment |
| 1192 | comment := &DiscussionComment{ |
| 1193 | ID: src.ID, |
| 1194 | URL: src.URL, |
| 1195 | Author: mapActorFromListNode(src.Author), |
| 1196 | Body: src.Body, |
| 1197 | CreatedAt: src.CreatedAt, |
| 1198 | IsAnswer: src.IsAnswer, |
| 1199 | UpvoteCount: src.UpvoteCount, |
| 1200 | } |
| 1201 | for _, rg := range src.ReactionGroups { |
| 1202 | comment.ReactionGroups = append(comment.ReactionGroups, ReactionGroup{ |
| 1203 | Content: rg.Content, |
| 1204 | TotalCount: rg.Users.TotalCount, |
| 1205 | }) |
| 1206 | } |
| 1207 | return comment, nil |
| 1208 | } |
| 1209 | |
| 1210 | // DeleteComment deletes a discussion comment or reply. |
| 1211 | func (c *discussionClient) DeleteComment(repo ghrepo.Interface, commentID string) error { |
nothing calls this directly
no test coverage detected