2020-01-23 20:05:54 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2020-06-25 14:54:04 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/acl"
|
2020-05-08 15:41:01 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/query"
|
2020-01-23 20:05:54 +01:00
|
|
|
"github.com/photoprism/photoprism/pkg/txt"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GET /api/v1/moments/time
|
2020-06-25 14:54:04 +02:00
|
|
|
func GetMomentsTime(router *gin.RouterGroup) {
|
2020-01-23 20:05:54 +01:00
|
|
|
router.GET("/moments/time", func(c *gin.Context) {
|
2020-06-25 14:54:04 +02:00
|
|
|
s := Auth(SessionID(c), acl.ResourceAlbums, acl.ActionExport)
|
|
|
|
|
|
|
|
if s.Invalid() {
|
2020-07-04 12:54:35 +02:00
|
|
|
AbortUnauthorized(c)
|
2020-01-23 20:05:54 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-05-29 12:21:17 +02:00
|
|
|
result, err := query.MomentsTime(1)
|
2020-01-23 20:05:54 +01:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": txt.UcFirst(err.Error())})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, result)
|
|
|
|
})
|
|
|
|
}
|