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
---
## 更新指南
### 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. 修复 - 插件计费错误。
11. 修复 - 插件计费错误。

View File

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

View File

@ -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();
// 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;
// if (documents.length === 0) return;
// Update in batches
await MongoDatasetData.updateMany(
{ _id: { $in: documents.map((doc) => doc._id) } },
{
$unset: {
initFullText: 1
// fullTextToken: 1
}
}
);
// // 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);
};
// success += documents.length;
// console.log('Delete success:', success);
// await batchUpdateFields(batchSize);
// };

View File

@ -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()
]);