From 5dee4c4559c8ca51377e5671d8f24e90c8be3958 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Fri, 10 Jan 2025 12:18:19 +0800 Subject: [PATCH 1/2] feat: init 4818 --- projects/app/src/pages/api/admin/initv4818.ts | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/projects/app/src/pages/api/admin/initv4818.ts b/projects/app/src/pages/api/admin/initv4818.ts index 0374d93c29ec..dab3ed704768 100644 --- a/projects/app/src/pages/api/admin/initv4818.ts +++ b/projects/app/src/pages/api/admin/initv4818.ts @@ -12,7 +12,7 @@ import { NextApiRequest, NextApiResponse } from 'next'; 1. 先用 4.8.18-tmp 版本,会同时有 MongoDatasetData 和 MongoDatasetDataText 两个表和索引,依然是 MongoDatasetData 生效。会同步更新两张表数据。 2. 执行升级脚本,不要删除 MongoDatasetData 里的数据。 3. 切换正式版镜像,让 MongoDatasetDataText 生效。 - 4. 删除 MongoDatasetData 里的索引和多余字段。 + 4. 删除 MongoDatasetData 里的索引和多余字段。(4819 再删 */ let success = 0; async function handler(req: NextApiRequest, res: NextApiResponse) { @@ -26,7 +26,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { console.log('Init data time:', Date.now() - start); success = 0; - await batchUpdateFields(); + // await batchUpdateFields(); return { success: true }; } @@ -79,26 +79,26 @@ const initData = async (batchSize: number) => { } }; -const batchUpdateFields = async (batchSize = 2000) => { - // Find documents that still have these fields - const documents = await MongoDatasetData.find({ initFullText: { $exists: true } }, '_id') - .limit(batchSize) - .lean(); - - if (documents.length === 0) return; - - // Update in batches - await MongoDatasetData.updateMany( - { _id: { $in: documents.map((doc) => doc._id) } }, - { - $unset: { - initFullText: 1 - // fullTextToken: 1 - } - } - ); - - success += documents.length; - console.log('Delete success:', success); - await batchUpdateFields(batchSize); -}; +// const batchUpdateFields = async (batchSize = 2000) => { +// // Find documents that still have these fields +// const documents = await MongoDatasetData.find({ initFullText: { $exists: true } }, '_id') +// .limit(batchSize) +// .lean(); + +// if (documents.length === 0) return; + +// // Update in batches +// await MongoDatasetData.updateMany( +// { _id: { $in: documents.map((doc) => doc._id) } }, +// { +// $unset: { +// initFullText: 1 +// // fullTextToken: 1 +// } +// } +// ); + +// success += documents.length; +// console.log('Delete success:', success); +// await batchUpdateFields(batchSize); +// }; From 36b8acb9446d222424ef40ba25141dad5586b415 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Fri, 10 Jan 2025 12:22:43 +0800 Subject: [PATCH 2/2] share page avatar --- .../zh-cn/docs/development/upgrading/4818.md | 23 +++++++++++++++---- packages/service/support/user/schema.ts | 2 +- .../src/pages/api/core/chat/outLink/init.ts | 7 ++---- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/docSite/content/zh-cn/docs/development/upgrading/4818.md b/docSite/content/zh-cn/docs/development/upgrading/4818.md index e6665959cb1b..0f102c2d6181 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/4818.md +++ b/docSite/content/zh-cn/docs/development/upgrading/4818.md @@ -7,11 +7,26 @@ toc: true weight: 806 --- +## 更新指南 + +### 2. 运行升级脚本 + +从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的 `rootkey`;{{host}} 替换成**FastGPT 域名**。 + +```bash +curl --location --request POST 'https://{{host}}/api/admin/initv4818' \ +--header 'rootkey: {{rootkey}}' \ +--header 'Content-Type: application/json' +``` + +会迁移全文检索表,时间较长,迁移期间全文检索会失效,日志中会打印已经迁移的数据长度。 + + ## 完整更新内容 -1. -2. 新增 - 支持部门架构权限模式。 -3. 新增 - 支持配置自定跨域安全策略,默认全开。 +1. 新增 - 支持部门架构权限模式。 +2. 新增 - 支持配置自定跨域安全策略,默认全开。 +3. 优化 - 分享链接随机生成用户头像。 4. 优化 - 图片上传安全校验。并增加头像图片唯一存储,确保不会累计存储。 5. 优化 - Mongo 全文索引表分离。 6. 优化 - 知识库检索查询语句合并,同时减少查库数量。 @@ -19,4 +34,4 @@ weight: 806 8. 优化 - 异步读取文件内容,减少进程阻塞。 9. 优化 - 文件阅读,HTML 直接下载,不允许在线阅读。 10. 修复 - HTML 文件上传,base64 图片无法自动转图片链接。 -11. 修复 - 插件计费错误。 \ No newline at end of file +11. 修复 - 插件计费错误。 diff --git a/packages/service/support/user/schema.ts b/packages/service/support/user/schema.ts index 97de98295273..10094ee6fbbb 100644 --- a/packages/service/support/user/schema.ts +++ b/packages/service/support/user/schema.ts @@ -35,7 +35,7 @@ const UserSchema = new Schema({ }, avatar: { type: String, - default: getRandomUserAvatar() + default: () => getRandomUserAvatar() }, promotionRate: { diff --git a/projects/app/src/pages/api/core/chat/outLink/init.ts b/projects/app/src/pages/api/core/chat/outLink/init.ts index eaf9a0660f79..8a5baf33504e 100644 --- a/projects/app/src/pages/api/core/chat/outLink/init.ts +++ b/projects/app/src/pages/api/core/chat/outLink/init.ts @@ -18,13 +18,10 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { let { chatId, shareId, outLinkUid } = req.query as InitOutLinkChatProps; // auth link permission - const { outLinkConfig, uid, appId } = await authOutLink({ shareId, outLinkUid }); + const { uid, appId } = await authOutLink({ shareId, outLinkUid }); // auth app permission - const [tmb, chat, app] = await Promise.all([ - MongoTeamMember.findById(outLinkConfig.tmbId, '_id userId') - .populate<{ user: UserModelSchema }>('user', 'avatar') - .lean(), + const [chat, app] = await Promise.all([ MongoChat.findOne({ appId, chatId, shareId }).lean(), MongoApp.findById(appId).lean() ]);