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

Method appUpdateComment

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

Source from the content-addressed store, hash-verified

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