Changeset 0.8.6 (#49)
This commit is contained in:
@@ -523,7 +523,7 @@ func (h *AdminHandler) ListGlobalConfigs(c *gin.Context) {
|
||||
(api_key_encrypted IS NOT NULL AND api_key_encrypted != '') as has_key,
|
||||
created_at
|
||||
FROM api_configs
|
||||
WHERE user_id IS NULL
|
||||
WHERE user_id IS NULL AND team_id IS NULL
|
||||
ORDER BY created_at ASC
|
||||
`)
|
||||
if err != nil {
|
||||
@@ -605,7 +605,7 @@ func (h *AdminHandler) UpdateGlobalConfig(c *gin.Context) {
|
||||
|
||||
sets = append(sets, "updated_at = NOW()")
|
||||
args = append(args, configID)
|
||||
query := "UPDATE api_configs SET " + strings.Join(sets, ", ") + " WHERE id = $" + strconv.Itoa(argN) + " AND user_id IS NULL"
|
||||
query := "UPDATE api_configs SET " + strings.Join(sets, ", ") + " WHERE id = $" + strconv.Itoa(argN) + " AND user_id IS NULL AND team_id IS NULL"
|
||||
result, err := database.DB.Exec(query, args...)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to update config"})
|
||||
@@ -624,7 +624,7 @@ func (h *AdminHandler) DeleteGlobalConfig(c *gin.Context) {
|
||||
configID := c.Param("id")
|
||||
|
||||
result, err := database.DB.Exec(
|
||||
`DELETE FROM api_configs WHERE id = $1 AND user_id IS NULL`,
|
||||
`DELETE FROM api_configs WHERE id = $1 AND user_id IS NULL AND team_id IS NULL`,
|
||||
configID,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -666,7 +666,7 @@ func (h *AdminHandler) ListModelConfigs(c *gin.Context) {
|
||||
mc.visibility, mc.capabilities, mc.created_at, mc.updated_at
|
||||
FROM model_configs mc
|
||||
JOIN api_configs ac ON mc.api_config_id = ac.id
|
||||
WHERE ac.user_id IS NULL
|
||||
WHERE ac.user_id IS NULL AND ac.team_id IS NULL
|
||||
ORDER BY ac.name, mc.model_id
|
||||
`)
|
||||
if err != nil {
|
||||
@@ -697,7 +697,7 @@ func (h *AdminHandler) FetchModels(c *gin.Context) {
|
||||
rows, err := database.DB.Query(`
|
||||
SELECT id, provider, endpoint, api_key_encrypted, custom_headers
|
||||
FROM api_configs
|
||||
WHERE user_id IS NULL AND is_active = true
|
||||
WHERE user_id IS NULL AND team_id IS NULL AND is_active = true
|
||||
`)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to list configs"})
|
||||
@@ -857,7 +857,7 @@ func (h *AdminHandler) BulkUpdateModels(c *gin.Context) {
|
||||
|
||||
result, err := database.DB.Exec(
|
||||
`UPDATE model_configs SET visibility = $1, updated_at = NOW()
|
||||
WHERE api_config_id IN (SELECT id FROM api_configs WHERE user_id IS NULL)`,
|
||||
WHERE api_config_id IN (SELECT id FROM api_configs WHERE user_id IS NULL AND team_id IS NULL)`,
|
||||
req.Visibility,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user