share page avatar (#3558)

* feat: init 4818

* share page avatar
This commit is contained in:
Archer 2025-01-10 13:37:48 +08:00 committed by GitHub
parent b26345dcaa
commit 1c0b323b1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 44 additions and 32 deletions

View File

@ -7,11 +7,26 @@ toc: true
weight: 806 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. 1. 新增 - 支持部门架构权限模式。
2. 新增 - 支持部门架构权限模式。 2. 新增 - 支持配置自定跨域安全策略,默认全开
3. 新增 - 支持配置自定跨域安全策略,默认全开。 3. 优化 - 分享链接随机生成用户头像
4. 优化 - 图片上传安全校验。并增加头像图片唯一存储,确保不会累计存储。 4. 优化 - 图片上传安全校验。并增加头像图片唯一存储,确保不会累计存储。
5. 优化 - Mongo 全文索引表分离。 5. 优化 - Mongo 全文索引表分离。
6. 优化 - 知识库检索查询语句合并,同时减少查库数量。 6. 优化 - 知识库检索查询语句合并,同时减少查库数量。

View File

@ -35,7 +35,7 @@ const UserSchema = new Schema({
}, },
avatar: { avatar: {
type: String, type: String,
default: getRandomUserAvatar() default: () => getRandomUserAvatar()
}, },
promotionRate: { promotionRate: {

View File

@ -12,7 +12,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
1. 4.8.18-tmp MongoDatasetData MongoDatasetDataText MongoDatasetData 1. 4.8.18-tmp MongoDatasetData MongoDatasetDataText MongoDatasetData
2. MongoDatasetData 2. MongoDatasetData
3. MongoDatasetDataText 3. MongoDatasetDataText
4. MongoDatasetData 4. MongoDatasetData 4819
*/ */
let success = 0; let success = 0;
async function handler(req: NextApiRequest, res: NextApiResponse) { 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); console.log('Init data time:', Date.now() - start);
success = 0; success = 0;
await batchUpdateFields(); // await batchUpdateFields();
return { success: true }; return { success: true };
} }
@ -79,26 +79,26 @@ const initData = async (batchSize: number) => {
} }
}; };
const batchUpdateFields = async (batchSize = 2000) => { // const batchUpdateFields = async (batchSize = 2000) => {
// Find documents that still have these fields // // Find documents that still have these fields
const documents = await MongoDatasetData.find({ initFullText: { $exists: true } }, '_id') // const documents = await MongoDatasetData.find({ initFullText: { $exists: true } }, '_id')
.limit(batchSize) // .limit(batchSize)
.lean(); // .lean();
if (documents.length === 0) return; // if (documents.length === 0) return;
// Update in batches // // Update in batches
await MongoDatasetData.updateMany( // await MongoDatasetData.updateMany(
{ _id: { $in: documents.map((doc) => doc._id) } }, // { _id: { $in: documents.map((doc) => doc._id) } },
{ // {
$unset: { // $unset: {
initFullText: 1 // initFullText: 1
// fullTextToken: 1 // // fullTextToken: 1
} // }
} // }
); // );
success += documents.length; // success += documents.length;
console.log('Delete success:', success); // console.log('Delete success:', success);
await batchUpdateFields(batchSize); // await batchUpdateFields(batchSize);
}; // };

View File

@ -18,13 +18,10 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
let { chatId, shareId, outLinkUid } = req.query as InitOutLinkChatProps; let { chatId, shareId, outLinkUid } = req.query as InitOutLinkChatProps;
// auth link permission // auth link permission
const { outLinkConfig, uid, appId } = await authOutLink({ shareId, outLinkUid }); const { uid, appId } = await authOutLink({ shareId, outLinkUid });
// auth app permission // auth app permission
const [tmb, chat, app] = await Promise.all([ const [chat, app] = await Promise.all([
MongoTeamMember.findById(outLinkConfig.tmbId, '_id userId')
.populate<{ user: UserModelSchema }>('user', 'avatar')
.lean(),
MongoChat.findOne({ appId, chatId, shareId }).lean(), MongoChat.findOne({ appId, chatId, shareId }).lean(),
MongoApp.findById(appId).lean() MongoApp.findById(appId).lean()
]); ]);