Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

share page avatar #3558

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions docSite/content/zh-cn/docs/development/upgrading/4818.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,31 @@ 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. 优化 - 知识库检索查询语句合并,同时减少查库数量。
7. 优化 - 文件编码检测,减少 CSV 文件乱码概率。
8. 优化 - 异步读取文件内容,减少进程阻塞。
9. 优化 - 文件阅读,HTML 直接下载,不允许在线阅读。
10. 修复 - HTML 文件上传,base64 图片无法自动转图片链接。
11. 修复 - 插件计费错误。
11. 修复 - 插件计费错误。
2 changes: 1 addition & 1 deletion packages/service/support/user/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const UserSchema = new Schema({
},
avatar: {
type: String,
default: getRandomUserAvatar()
default: () => getRandomUserAvatar()
},

promotionRate: {
Expand Down
50 changes: 25 additions & 25 deletions projects/app/src/pages/api/admin/initv4818.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 };
}
Expand Down Expand Up @@ -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);
// };
7 changes: 2 additions & 5 deletions projects/app/src/pages/api/core/chat/outLink/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
]);
Expand Down
Loading