feat(market): admin用户前台导入的Agent/Skill/MCP自动标记为官方(official)

- POST /market/apps: 当 current_user.role == "admin" 时,source 强制设为 official
- 前端发送 source:/user/ 也会被后端覆盖为 official
- 前台卡片已有 official-badge 徽章展示,无需额外前端改动
This commit is contained in:
deploy committed 2026-07-15 18:58:15 +08:00
1 parent 6416fb4651
commit b88f883d44
1 file changed
+10 -1
+10 -1
View File
@@ -340,13 +340,22 @@ def upload_app(
detail=f"Agent 连接校验未通过:{v['detail']}", detail=f"Agent 连接校验未通过:{v['detail']}",
) )
# source 判定:管理员(admin 角色)通过前台市场导入/开发的 Agent/Skill/MCP
# 统一标记为官方(official),其余用户按请求或默认为 user。
if current_user.role == "admin":
app_source = "official"
elif req.source and req.source in ("official", "user"):
app_source = req.source
else:
app_source = "user"
app = MarketApp( app = MarketApp(
id=gen_uuid(), id=gen_uuid(),
name=req.name, name=req.name,
description=req.description, description=req.description,
icon=req.icon, icon=req.icon,
type=req.type if req.type in ("skill","agent","mcp") else "skill", type=req.type if req.type in ("skill","agent","mcp") else "skill",
source=req.source if req.source in ("official","user") else "user", source=app_source,
platform=req.platform, platform=req.platform,
price=req.price, price=req.price,
install_count=0, install_count=0,