Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
da1126ed
authored
Sep 12, 2024
by
Archer
Committed by
GitHub
Sep 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: share init error (#2690)
parent
56281d92
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
27 deletions
+13
-27
projects/app/src/global/core/chat/utils.ts
+2
-0
projects/app/src/pages/api/core/chat/getResData.ts
+11
-6
projects/app/src/pages/api/core/chat/outLink/init.ts
+0
-11
projects/app/src/pages/api/core/chat/team/init.ts
+0
-10
No files found.
projects/app/src/global/core/chat/utils.ts
View file @
da1126ed
...
@@ -18,6 +18,8 @@ export function transformPreviewHistories(histories: ChatItemType[]) {
...
@@ -18,6 +18,8 @@ export function transformPreviewHistories(histories: ChatItemType[]) {
export
function
addStatisticalDataToHistoryItem
(
historyItem
:
ChatItemType
)
{
export
function
addStatisticalDataToHistoryItem
(
historyItem
:
ChatItemType
)
{
if
(
historyItem
.
obj
!==
ChatRoleEnum
.
AI
)
return
historyItem
;
if
(
historyItem
.
obj
!==
ChatRoleEnum
.
AI
)
return
historyItem
;
if
(
historyItem
.
totalQuoteList
!==
undefined
)
return
historyItem
;
if
(
historyItem
.
totalQuoteList
!==
undefined
)
return
historyItem
;
// Flat children
const
flatResData
:
ChatHistoryItemResType
[]
=
const
flatResData
:
ChatHistoryItemResType
[]
=
historyItem
.
responseData
historyItem
.
responseData
?.
map
((
item
)
=>
{
?.
map
((
item
)
=>
{
...
...
projects/app/src/pages/api/core/chat/getResData.ts
View file @
da1126ed
...
@@ -10,6 +10,7 @@ import { NextAPI } from '@/service/middleware/entry';
...
@@ -10,6 +10,7 @@ import { NextAPI } from '@/service/middleware/entry';
import
{
ChatHistoryItemResType
}
from
'@fastgpt/global/core/chat/type'
;
import
{
ChatHistoryItemResType
}
from
'@fastgpt/global/core/chat/type'
;
import
{
OutLinkChatAuthProps
}
from
'@fastgpt/global/support/permission/chat'
;
import
{
OutLinkChatAuthProps
}
from
'@fastgpt/global/support/permission/chat'
;
import
{
authApp
}
from
'@fastgpt/service/support/permission/app/auth'
;
import
{
authApp
}
from
'@fastgpt/service/support/permission/app/auth'
;
import
{
filterPublicNodeResponseData
}
from
'@fastgpt/global/core/chat/utils'
;
export
type
getResDataQuery
=
OutLinkChatAuthProps
&
{
export
type
getResDataQuery
=
OutLinkChatAuthProps
&
{
chatId
?:
string
;
chatId
?:
string
;
...
@@ -48,14 +49,18 @@ async function handler(
...
@@ -48,14 +49,18 @@ async function handler(
});
});
}
}
const
chatData
=
await
MongoChatItem
.
findOne
({
const
chatData
=
await
MongoChatItem
.
findOne
(
appId
,
{
chatId
,
appId
,
dataId
chatId
,
});
dataId
},
'obj responseData'
).
lean
();
if
(
chatData
?.
obj
===
ChatRoleEnum
.
AI
)
{
if
(
chatData
?.
obj
===
ChatRoleEnum
.
AI
)
{
return
chatData
.
responseData
||
{};
const
data
=
chatData
.
responseData
||
{};
return
req
.
query
.
shareId
?
filterPublicNodeResponseData
(
data
)
:
data
;
}
else
return
{};
}
else
return
{};
}
}
...
...
projects/app/src/pages/api/core/chat/outLink/init.ts
View file @
da1126ed
import
type
{
NextApiRequest
,
NextApiResponse
}
from
'next'
;
import
type
{
NextApiRequest
,
NextApiResponse
}
from
'next'
;
import
{
jsonRes
}
from
'@fastgpt/service/common/response'
;
import
{
jsonRes
}
from
'@fastgpt/service/common/response'
;
import
{
connectToDatabase
}
from
'@/service/mongo'
;
import
type
{
InitChatResponse
,
InitOutLinkChatProps
}
from
'@/global/core/chat/api.d'
;
import
type
{
InitChatResponse
,
InitOutLinkChatProps
}
from
'@/global/core/chat/api.d'
;
import
{
getGuideModule
,
getAppChatConfig
}
from
'@fastgpt/global/core/workflow/utils'
;
import
{
getGuideModule
,
getAppChatConfig
}
from
'@fastgpt/global/core/workflow/utils'
;
import
{
getChatModelNameListByModules
}
from
'@/service/core/app/workflow'
;
import
{
getChatModelNameListByModules
}
from
'@/service/core/app/workflow'
;
...
@@ -9,11 +8,9 @@ import { getChatItems } from '@fastgpt/service/core/chat/controller';
...
@@ -9,11 +8,9 @@ import { getChatItems } from '@fastgpt/service/core/chat/controller';
import
{
MongoTeamMember
}
from
'@fastgpt/service/support/user/team/teamMemberSchema'
;
import
{
MongoTeamMember
}
from
'@fastgpt/service/support/user/team/teamMemberSchema'
;
import
{
authOutLink
}
from
'@/service/support/permission/auth/outLink'
;
import
{
authOutLink
}
from
'@/service/support/permission/auth/outLink'
;
import
{
MongoApp
}
from
'@fastgpt/service/core/app/schema'
;
import
{
MongoApp
}
from
'@fastgpt/service/core/app/schema'
;
import
{
filterPublicNodeResponseData
}
from
'@fastgpt/global/core/chat/utils'
;
import
{
AppErrEnum
}
from
'@fastgpt/global/common/error/code/app'
;
import
{
AppErrEnum
}
from
'@fastgpt/global/common/error/code/app'
;
import
{
MongoChat
}
from
'@fastgpt/service/core/chat/chatSchema'
;
import
{
MongoChat
}
from
'@fastgpt/service/core/chat/chatSchema'
;
import
{
ChatErrEnum
}
from
'@fastgpt/global/common/error/code/chat'
;
import
{
ChatErrEnum
}
from
'@fastgpt/global/common/error/code/chat'
;
import
{
ChatRoleEnum
}
from
'@fastgpt/global/core/chat/constants'
;
import
{
getAppLatestVersion
}
from
'@fastgpt/service/core/app/controller'
;
import
{
getAppLatestVersion
}
from
'@fastgpt/service/core/app/controller'
;
import
{
FlowNodeTypeEnum
}
from
'@fastgpt/global/core/workflow/node/constant'
;
import
{
FlowNodeTypeEnum
}
from
'@fastgpt/global/core/workflow/node/constant'
;
import
{
AppTypeEnum
}
from
'@fastgpt/global/core/app/constants'
;
import
{
AppTypeEnum
}
from
'@fastgpt/global/core/app/constants'
;
...
@@ -56,14 +53,6 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
...
@@ -56,14 +53,6 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
getAppLatestVersion
(
app
.
_id
,
app
)
getAppLatestVersion
(
app
.
_id
,
app
)
]);
]);
// pick share response field
app
.
type
!==
AppTypeEnum
.
plugin
&&
histories
.
forEach
((
item
)
=>
{
if
(
item
.
obj
===
ChatRoleEnum
.
AI
)
{
item
.
responseData
=
filterPublicNodeResponseData
({
flowResponses
:
item
.
responseData
});
}
});
jsonRes
<
InitChatResponse
>
(
res
,
{
jsonRes
<
InitChatResponse
>
(
res
,
{
data
:
{
data
:
{
chatId
,
chatId
,
...
...
projects/app/src/pages/api/core/chat/team/init.ts
View file @
da1126ed
...
@@ -11,8 +11,6 @@ import { AppErrEnum } from '@fastgpt/global/common/error/code/app';
...
@@ -11,8 +11,6 @@ import { AppErrEnum } from '@fastgpt/global/common/error/code/app';
import
{
authTeamSpaceToken
}
from
'@/service/support/permission/auth/team'
;
import
{
authTeamSpaceToken
}
from
'@/service/support/permission/auth/team'
;
import
{
MongoTeam
}
from
'@fastgpt/service/support/user/team/teamSchema'
;
import
{
MongoTeam
}
from
'@fastgpt/service/support/user/team/teamSchema'
;
import
{
ChatErrEnum
}
from
'@fastgpt/global/common/error/code/chat'
;
import
{
ChatErrEnum
}
from
'@fastgpt/global/common/error/code/chat'
;
import
{
filterPublicNodeResponseData
}
from
'@fastgpt/global/core/chat/utils'
;
import
{
ChatRoleEnum
}
from
'@fastgpt/global/core/chat/constants'
;
import
{
getAppLatestVersion
}
from
'@fastgpt/service/core/app/controller'
;
import
{
getAppLatestVersion
}
from
'@fastgpt/service/core/app/controller'
;
import
{
FlowNodeTypeEnum
}
from
'@fastgpt/global/core/workflow/node/constant'
;
import
{
FlowNodeTypeEnum
}
from
'@fastgpt/global/core/workflow/node/constant'
;
import
{
AppTypeEnum
}
from
'@fastgpt/global/core/app/constants'
;
import
{
AppTypeEnum
}
from
'@fastgpt/global/core/app/constants'
;
...
@@ -57,14 +55,6 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
...
@@ -57,14 +55,6 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
getAppLatestVersion
(
app
.
_id
,
app
)
getAppLatestVersion
(
app
.
_id
,
app
)
]);
]);
// pick share response field
app
.
type
!==
AppTypeEnum
.
plugin
&&
histories
.
forEach
((
item
)
=>
{
if
(
item
.
obj
===
ChatRoleEnum
.
AI
)
{
item
.
responseData
=
filterPublicNodeResponseData
({
flowResponses
:
item
.
responseData
});
}
});
jsonRes
<
InitChatResponse
>
(
res
,
{
jsonRes
<
InitChatResponse
>
(
res
,
{
data
:
{
data
:
{
chatId
,
chatId
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment