photoprism/internal/api/api_client_config.go
Michael Mayer e3bb8b19dd Routing: Prefix frontend UI routes with /library #840 #2466
Also improves migrations and updates the db schema docs.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-10-15 21:54:11 +02:00

31 lines
756 B
Go

package api
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/photoprism/photoprism/internal/event"
"github.com/photoprism/photoprism/internal/get"
)
// UpdateClientConfig publishes updated client configuration values over the websocket connections.
func UpdateClientConfig() {
event.Publish("config.updated", event.Data{"config": get.Config().ClientUser(false)})
}
// 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))
conf := get.Config()
if s == nil {
c.JSON(http.StatusOK, conf.ClientPublic())
} else {
c.JSON(http.StatusOK, conf.ClientSession(s))
}
})
}