mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-20 14:13:23 +00:00
Per naming directive: avoid unnecessary compound words, one clean name. Renames the router func + the ApiController method + all ~30 callers/tests/ comments; local effectiveOrg vars → org; test GlobalAdmin→SuperAdmin (matches the one super-admin rule). Pure rename — no behavior change; build + vet + gofumpt clean, org-resolver tests green. Co-authored-by: hanzo-dev <[email protected]>
63 lines
1.8 KiB
Go
63 lines
1.8 KiB
Go
// Copyright 2023-2025 Hanzo AI Inc. All Rights Reserved.
|
|
// Portions Copyright 2025 The OpenAgent Authors. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package controllers
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hanzoai/ai/i18n"
|
|
"github.com/hanzoai/ai/object"
|
|
"github.com/hanzoai/ai/util"
|
|
)
|
|
|
|
func addRecord(c *ApiController, userName string, requestUri string, lang string) error {
|
|
record, err := object.NewRecord(c.Ctx)
|
|
if err != nil {
|
|
return fmt.Errorf("%s", fmt.Sprintf(i18n.Translate(lang, "NewRecord() error: %s\n"), err.Error()))
|
|
}
|
|
|
|
record.User = userName
|
|
if requestUri != "" {
|
|
record.RequestUri = requestUri
|
|
}
|
|
|
|
record.Organization = c.GetOrg()
|
|
|
|
_, _, err = object.AddRecord(record, c.GetAcceptLanguage())
|
|
return err
|
|
}
|
|
|
|
func addRecordForFile(c *ApiController, userName string, action string, sessionId string, key string, filename string, isLeaf bool, lang string) error {
|
|
typ := "Folder"
|
|
if isLeaf {
|
|
typ = "File"
|
|
}
|
|
|
|
_, storeName, err := util.GetOwnerAndNameFromIdWithError(sessionId)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
path := fmt.Sprintf("/%s/%s", key, filename)
|
|
if filename == "" {
|
|
path = key
|
|
}
|
|
|
|
text := fmt.Sprintf("%s%s, Session: %s, Path: %s", action, typ, storeName, path)
|
|
err = addRecord(c, userName, text, lang)
|
|
return err
|
|
}
|