2020-01-23 19:05:54 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2022-08-31 15:42:57 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
2020-06-25 12:54:04 +00:00
|
|
|
"github.com/photoprism/photoprism/internal/acl"
|
2022-10-15 19:54:11 +00:00
|
|
|
"github.com/photoprism/photoprism/internal/get"
|
2020-05-08 13:41:01 +00:00
|
|
|
"github.com/photoprism/photoprism/internal/query"
|
2020-01-23 19:05:54 +00:00
|
|
|
"github.com/photoprism/photoprism/pkg/txt"
|
|
|
|
)
|
|
|
|
|
2022-09-28 07:01:17 +00:00
|
|
|
// GetMomentsTime returns monthly albums as JSON.
|
|
|
|
//
|
2020-01-23 19:05:54 +00:00
|
|
|
// GET /api/v1/moments/time
|
2020-06-25 12:54:04 +00:00
|
|
|
func GetMomentsTime(router *gin.RouterGroup) {
|
2020-01-23 19:05:54 +00:00
|
|
|
router.GET("/moments/time", func(c *gin.Context) {
|
2022-09-28 07:01:17 +00:00
|
|
|
s := Auth(c, acl.ResourceCalendar, acl.ActionSearch)
|
2020-06-25 12:54:04 +00:00
|
|
|
|
2022-09-28 07:01:17 +00:00
|
|
|
if s.Abort(c) {
|
2020-01-23 19:05:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-10-15 19:54:11 +00:00
|
|
|
conf := get.Config()
|
2022-08-31 15:42:57 +00:00
|
|
|
|
|
|
|
result, err := query.MomentsTime(1, conf.Settings().Features.Private)
|
2020-01-23 19:05:54 +00:00
|
|
|
|
|
|
|
if err != nil {
|
2022-04-15 07:42:07 +00:00
|
|
|
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": txt.UpperFirst(err.Error())})
|
2020-01-23 19:05:54 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, result)
|
|
|
|
})
|
|
|
|
}
|