mirror of
https://github.com/sbondCo/Watcharr.git
synced 2026-08-07 07:14:44 +00:00
Remove AddActivity endpoint
it isn't used and is only a way for others to potentially add activity to other peoples watched entries since user owning the watched entry is not validated on the endpoint. Co-Authored-By: Dreddy <24421368+dredsen@users.noreply.github.com>
This commit is contained in:
@@ -35,6 +35,11 @@ func (s *Service) GetActivity(
|
||||
return *activity, nil
|
||||
}
|
||||
|
||||
// NOTE: Currently this function doesn't verify if `userId` owns the referenced
|
||||
// watched item at `ar.WatchedID`. If we ever need this function to work from an
|
||||
// "AddActivity" endpoint on the API, we should create another func that has
|
||||
// that validation, since this func is only for internal operations!
|
||||
// AddActivity: Only for internal use.
|
||||
func (s *Service) AddActivity(
|
||||
userId uint,
|
||||
ar domain.ActivityAddProps,
|
||||
|
||||
@@ -27,7 +27,6 @@ func (r *Router) AddRoutes() {
|
||||
activity := r.br.Router.Group("/activity").Use(authmiddleware.AuthRequired(nil, r.br.Cfg))
|
||||
|
||||
activity.GET(":watchedId", r.GetActivity)
|
||||
activity.POST("", r.AddActivity)
|
||||
activity.PUT(":id", r.UpdateActivity)
|
||||
activity.DELETE(":id", r.DeleteActivity)
|
||||
}
|
||||
@@ -47,22 +46,6 @@ func (r *Router) GetActivity(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, activity)
|
||||
}
|
||||
|
||||
func (r *Router) AddActivity(c *gin.Context) {
|
||||
userId := c.MustGet("userId").(uint)
|
||||
var ar domain.ActivityAddRequest
|
||||
err := c.ShouldBindJSON(&ar)
|
||||
if err == nil {
|
||||
response, err := r.service.AddActivity(userId, ar)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusForbidden, router.ErrorResponse{Error: err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, response)
|
||||
return
|
||||
}
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, router.ErrorResponse{Error: err.Error()})
|
||||
}
|
||||
|
||||
func (r *Router) UpdateActivity(c *gin.Context) {
|
||||
userId := c.MustGet("userId").(uint)
|
||||
id, err := strconv.ParseUint(c.Param("id"), 10, 32)
|
||||
|
||||
Reference in New Issue
Block a user