photoprism/internal/api/moments_time.go
Michael Mayer 78665e5869 Albums: Ignore private pictures only if feature is enabled #2570
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-08-31 17:42:57 +02:00

35 lines
788 B
Go

package api
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/photoprism/photoprism/internal/acl"
"github.com/photoprism/photoprism/internal/query"
"github.com/photoprism/photoprism/internal/service"
"github.com/photoprism/photoprism/pkg/txt"
)
// GET /api/v1/moments/time
func GetMomentsTime(router *gin.RouterGroup) {
router.GET("/moments/time", func(c *gin.Context) {
s := Auth(SessionID(c), acl.ResourceAlbums, acl.ActionExport)
if s.Invalid() {
AbortUnauthorized(c)
return
}
conf := service.Config()
result, err := query.MomentsTime(1, conf.Settings().Features.Private)
if err != nil {
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": txt.UpperFirst(err.Error())})
return
}
c.JSON(http.StatusOK, result)
})
}