mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
35
internal/api/api_client_config.go
Normal file
35
internal/api/api_client_config.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/event"
|
||||
"github.com/photoprism/photoprism/internal/service"
|
||||
)
|
||||
|
||||
// UpdateClientConfig publishes updated client configuration values over the websocket connections.
|
||||
func UpdateClientConfig() {
|
||||
event.Publish("config.updated", event.Data{"config": service.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 := service.Config()
|
||||
|
||||
if s == nil {
|
||||
c.JSON(http.StatusOK, conf.ClientPublic())
|
||||
} else if s.User().IsVisitor() {
|
||||
c.JSON(http.StatusOK, conf.ClientShare())
|
||||
} else if s.User().IsRegistered() {
|
||||
c.JSON(http.StatusOK, conf.ClientSession(s))
|
||||
} else {
|
||||
c.JSON(http.StatusOK, conf.ClientPublic())
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user