MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / appUpdateComment

Method appUpdateComment

internal/server/app_api_write.go:321–349  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

319}
320
321func (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
351func (s *Server) appDeleteComment(w http.ResponseWriter, r *http.Request) {
352 ac := appContextFrom(r)

Callers

nothing calls this directly

Calls 15

appCommentOnItemMethod · 0.95
appReadmitBeforeWriteMethod · 0.95
appStoreMethod · 0.95
publishCommentEventMethod · 0.95
appContextFromFunction · 0.85
decodeAppJSONFunction · 0.85
writeErrorFunction · 0.85
writeInternalErrorFunction · 0.85
appActorFunction · 0.85
writeAppStoreErrorFunction · 0.85
appActorKindFunction · 0.85
writeAppJSONFunction · 0.85

Tested by

no test coverage detected