2020-01-23 20:05:54 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2022-08-31 17:42:57 +02:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
2020-06-25 14:54:04 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/acl"
|
2022-10-15 21:54:11 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/get"
|
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"
|
|
|
|
)
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// GetMomentsTime returns monthly albums as JSON.
|
|
|
|
//
|
2020-01-23 20:05:54 +01:00
|
|
|
// 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) {
|
2022-09-28 09:01:17 +02:00
|
|
|
s := Auth(c, acl.ResourceCalendar, acl.ActionSearch)
|
2020-06-25 14:54:04 +02:00
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
if s.Abort(c) {
|
2020-01-23 20:05:54 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-10-15 21:54:11 +02:00
|
|
|
conf := get.Config()
|
2022-08-31 17:42:57 +02:00
|
|
|
|
|
|
|
result, err := query.MomentsTime(1, conf.Settings().Features.Private)
|
2020-01-23 20:05:54 +01:00
|
|
|
|
|
|
|
if err != nil {
|
2022-04-15 09:42:07 +02:00
|
|
|
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": txt.UpperFirst(err.Error())})
|
2020-01-23 20:05:54 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, result)
|
|
|
|
})
|
|
|
|
}
|