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