AnnotationsApi: GET /api/annotations/:annotationId (#47739)

This commit is contained in:
Scott Bock
2022-05-16 17:16:36 +02:00
committed by GitHub
parent 2d4065600c
commit 3d922a4e67
4 changed files with 55 additions and 0 deletions
+20
View File
@@ -351,6 +351,26 @@ func (hs *HTTPServer) MassDeleteAnnotations(c *models.ReqContext) response.Respo
return response.Success("Annotations deleted")
}
func (hs *HTTPServer) GetAnnotationByID(c *models.ReqContext) response.Response {
annotationID, err := strconv.ParseInt(web.Params(c.Req)[":annotationId"], 10, 64)
if err != nil {
return response.Error(http.StatusBadRequest, "annotationId is invalid", err)
}
repo := annotations.GetRepository()
annotation, resp := findAnnotationByID(c.Req.Context(), repo, annotationID, c.SignedInUser)
if resp != nil {
return resp
}
if annotation.Email != "" {
annotation.AvatarUrl = dtos.GetGravatarUrl(annotation.Email)
}
return response.JSON(200, annotation)
}
func (hs *HTTPServer) DeleteAnnotationByID(c *models.ReqContext) response.Response {
annotationID, err := strconv.ParseInt(web.Params(c.Req)[":annotationId"], 10, 64)
if err != nil {