2022-09-28 09:01:17 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/event"
|
2022-10-15 21:54:11 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/get"
|
2022-09-28 09:01:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// UpdateClientConfig publishes updated client configuration values over the websocket connections.
|
|
|
|
func UpdateClientConfig() {
|
2022-10-15 21:54:11 +02:00
|
|
|
event.Publish("config.updated", event.Data{"config": get.Config().ClientUser(false)})
|
2022-09-28 09:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetClientConfig returns the client configuration values as JSON.
|
|
|
|
//
|
|
|
|
// GET /api/v1/config
|
|
|
|
func GetClientConfig(router *gin.RouterGroup) {
|
|
|
|
router.GET("/config", func(c *gin.Context) {
|
|
|
|
s := Session(SessionID(c))
|
2022-10-15 21:54:11 +02:00
|
|
|
conf := get.Config()
|
2022-09-28 09:01:17 +02:00
|
|
|
|
|
|
|
if s == nil {
|
|
|
|
c.JSON(http.StatusOK, conf.ClientPublic())
|
|
|
|
} else {
|
2022-10-13 22:11:02 +02:00
|
|
|
c.JSON(http.StatusOK, conf.ClientSession(s))
|
2022-09-28 09:01:17 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|