(w http.ResponseWriter, r *http.Request)
| 319 | } |
| 320 | |
| 321 | func (s *Server) appUpdateComment(w http.ResponseWriter, r *http.Request) { |
| 322 | ac := appContextFrom(r) |
| 323 | item, _, comment, ok := s.appCommentOnItem(w, r) |
| 324 | if !ok { |
| 325 | return |
| 326 | } |
| 327 | var in AppCommentUpdateRequest |
| 328 | if err := decodeAppJSON(r, &in); err != nil { |
| 329 | writeError(w, http.StatusBadRequest, "bad_request", err.Error()) |
| 330 | return |
| 331 | } |
| 332 | if !s.appReadmitBeforeWrite(w, r, item.ID, item.CollectionID) { |
| 333 | return |
| 334 | } |
| 335 | as, err := s.appStore() |
| 336 | if err != nil { |
| 337 | writeInternalError(w, err) |
| 338 | return |
| 339 | } |
| 340 | // Author only, no admin bypass: the appstore checks user AND install. |
| 341 | cw, err := as.UpdateCommentWrite(r.Context(), ac.appFenceSpec(), item.ID, comment.ID, in.Body, appActor(ac)) |
| 342 | if err != nil { |
| 343 | writeAppStoreError(w, err) |
| 344 | return |
| 345 | } |
| 346 | at := cw.Item |
| 347 | s.publishCommentEvent(sseCommentUpdated, ac.WorkspaceID, at.ID, cw.Comment.ID, at.Title, at.CollectionSlug, appActorKind(ac), "app") |
| 348 | writeAppJSON(w, http.StatusOK, appCommentDTO(cw.Comment, appCommentAuthorKind(ac))) |
| 349 | } |
| 350 | |
| 351 | func (s *Server) appDeleteComment(w http.ResponseWriter, r *http.Request) { |
| 352 | ac := appContextFrom(r) |
nothing calls this directly
no test coverage detected