Adding initial scaffolding to rename the repository
Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
parent
c7472582a7
commit
0f880ac1fa
46 changed files with 5707 additions and 674 deletions
54
internal/api/feedback.go
Normal file
54
internal/api/feedback.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/service"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/acl"
|
||||
"github.com/photoprism/photoprism/internal/form"
|
||||
"github.com/photoprism/photoprism/internal/i18n"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// POST /api/v1/feedback
|
||||
func SendFeedback(router *gin.RouterGroup) {
|
||||
router.POST("/feedback", func(c *gin.Context) {
|
||||
conf := service.Config()
|
||||
|
||||
if conf.Public() {
|
||||
Abort(c, http.StatusForbidden, i18n.ErrPublic)
|
||||
return
|
||||
}
|
||||
|
||||
s := Auth(SessionID(c), acl.ResourceFeedback, acl.ActionCreate)
|
||||
|
||||
if s.Invalid() {
|
||||
AbortUnauthorized(c)
|
||||
return
|
||||
}
|
||||
|
||||
conf.UpdateHub()
|
||||
|
||||
var f form.Feedback
|
||||
|
||||
if err := c.BindJSON(&f); err != nil {
|
||||
AbortBadRequest(c)
|
||||
return
|
||||
}
|
||||
|
||||
if f.Empty() {
|
||||
Abort(c, http.StatusBadRequest, i18n.ErrNoItemsSelected)
|
||||
return
|
||||
}
|
||||
|
||||
if err := conf.Hub().SendFeedback(f); err != nil {
|
||||
log.Error(err)
|
||||
AbortSaveFailed(c)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"code": http.StatusOK})
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue