fix: Z35 map Chinese display names to stable physical DB names
Keep Chinese on Binding for UI; Agents use user_{id} or db{hash}; sanitize on attach/heal/publish.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"aijianzhan/platform/internal/agentstore"
|
||||
"aijianzhan/platform/internal/authx"
|
||||
"aijianzhan/platform/internal/dbsync"
|
||||
"aijianzhan/platform/internal/schema"
|
||||
"aijianzhan/platform/internal/types"
|
||||
"aijianzhan/platform/internal/userstore"
|
||||
"aijianzhan/platform/internal/yuhticket"
|
||||
@@ -191,12 +192,12 @@ func (l *AuthLogic) bindUserHostSync(u *userstore.User, hostKey, name, localID,
|
||||
return nil, "", fmt.Errorf("host_key 已绑定其它公司")
|
||||
}
|
||||
online := fmt.Sprintf("%s_u%d", dbsync.ResolveOnlineDBID("", ch.ID), u.UserID)
|
||||
// DisplayName 可中文;Postgres 物理库名必须 [a-z][a-z0-9_]{1,47}(Z35)
|
||||
// 中文昵称可接受:写入 Binding 展示字段;物理库名映射为 user_{id} / 哈希(Z35)
|
||||
display := strings.TrimSpace(u.DisplayName)
|
||||
if display == "" {
|
||||
display = fmt.Sprintf("user_%d", u.UserID)
|
||||
}
|
||||
dbName := fmt.Sprintf("user_%d", u.UserID)
|
||||
dbName := schema.SafeSyncDatabaseName(display, acc.AgentID, u.UserID)
|
||||
updated, err := l.svcCtx.Agents.AttachSyncBind(l.ctx, acc.AgentID, u.TenantID, ch.ID, online, dbName, true)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
@@ -215,7 +216,7 @@ func (l *AuthLogic) bindUserHostSync(u *userstore.User, hostKey, name, localID,
|
||||
LocalDatabaseID: localID,
|
||||
OnlineDBID: online,
|
||||
ChannelID: ch.ID,
|
||||
DatabaseName: dbName,
|
||||
DatabaseName: display, // 可读名(可中文)
|
||||
DisplayName: display,
|
||||
Note: note,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user