CreateIssueComment creates the issue comment.
(ctx context.Context, req *connect.Request[v1pb.CreateIssueCommentRequest])
| 1241 | |
| 1242 | // CreateIssueComment creates the issue comment. |
| 1243 | func (s *IssueService) CreateIssueComment(ctx context.Context, req *connect.Request[v1pb.CreateIssueCommentRequest]) (*connect.Response[v1pb.IssueComment], error) { |
| 1244 | if req.Msg.IssueComment.Comment == "" { |
| 1245 | return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("issue comment is empty")) |
| 1246 | } |
| 1247 | user, ok := GetUserFromContext(ctx) |
| 1248 | if !ok { |
| 1249 | return nil, connect.NewError(connect.CodeInternal, errors.Errorf("user not found")) |
| 1250 | } |
| 1251 | |
| 1252 | issue, err := s.getIssueMessage(ctx, req.Msg.Parent) |
| 1253 | if err != nil { |
| 1254 | return nil, err |
| 1255 | } |
| 1256 | project, err := s.store.GetProject(ctx, &store.FindProjectMessage{Workspace: common.GetWorkspaceIDFromContext(ctx), ResourceID: &issue.ProjectID}) |
| 1257 | if err != nil { |
| 1258 | return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get project")) |
| 1259 | } |
| 1260 | if project == nil { |
| 1261 | return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("project %s not found", issue.ProjectID)) |
| 1262 | } |
| 1263 | |
| 1264 | ic, err := s.store.CreateIssueComments(ctx, user.Email, &store.IssueCommentMessage{ |
| 1265 | ProjectID: issue.ProjectID, |
| 1266 | IssueUID: issue.UID, |
| 1267 | Payload: &storepb.IssueCommentPayload{ |
| 1268 | Comment: req.Msg.IssueComment.Comment, |
| 1269 | }, |
| 1270 | }) |
| 1271 | if err != nil { |
| 1272 | return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to create issue comment: %v", err)) |
| 1273 | } |
| 1274 | |
| 1275 | return connect.NewResponse(convertToIssueComment(req.Msg.Parent, ic)), nil |
| 1276 | } |
| 1277 | |
| 1278 | // UpdateIssueComment updates the issue comment. |
| 1279 | func (s *IssueService) UpdateIssueComment(ctx context.Context, req *connect.Request[v1pb.UpdateIssueCommentRequest]) (*connect.Response[v1pb.IssueComment], error) { |
no test coverage detected