mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 06:47:02 +08:00
fix: gql result check for clean history (#7154)
This commit is contained in:
@@ -314,7 +314,7 @@ export class CopilotResolver {
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => String, {
|
@Mutation(() => [String], {
|
||||||
description: 'Cleanup sessions',
|
description: 'Cleanup sessions',
|
||||||
})
|
})
|
||||||
async cleanupCopilotSession(
|
async cleanupCopilotSession(
|
||||||
@@ -336,11 +336,10 @@ export class CopilotResolver {
|
|||||||
return new TooManyRequestsException('Server is busy');
|
return new TooManyRequestsException('Server is busy');
|
||||||
}
|
}
|
||||||
|
|
||||||
const ret = await this.chatSession.cleanup({
|
return await this.chatSession.cleanup({
|
||||||
...options,
|
...options,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => String, {
|
@Mutation(() => String, {
|
||||||
|
|||||||
@@ -514,24 +514,24 @@ export class ChatSessionService {
|
|||||||
|
|
||||||
// only mark action session as deleted
|
// only mark action session as deleted
|
||||||
// chat session always can be reuse
|
// chat session always can be reuse
|
||||||
{
|
const actionIds = (
|
||||||
const actionIds = (
|
await Promise.all(
|
||||||
await Promise.all(
|
sessions.map(({ id, promptName }) =>
|
||||||
sessions.map(({ id, promptName }) =>
|
this.prompt
|
||||||
this.prompt
|
.get(promptName)
|
||||||
.get(promptName)
|
.then(prompt => ({ id, action: !!prompt?.action }))
|
||||||
.then(prompt => ({ id, action: !!prompt?.action }))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.filter(({ action }) => action)
|
)
|
||||||
.map(({ id }) => id);
|
.filter(({ action }) => action)
|
||||||
|
.map(({ id }) => id);
|
||||||
|
|
||||||
await tx.aiSession.updateMany({
|
await tx.aiSession.updateMany({
|
||||||
where: { id: { in: actionIds } },
|
where: { id: { in: actionIds } },
|
||||||
data: { deletedAt: new Date() },
|
data: { deletedAt: new Date() },
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
return [...sessionIds, ...actionIds];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ type Mutation {
|
|||||||
changePassword(newPassword: String!, token: String!): UserType!
|
changePassword(newPassword: String!, token: String!): UserType!
|
||||||
|
|
||||||
"""Cleanup sessions"""
|
"""Cleanup sessions"""
|
||||||
cleanupCopilotSession(options: DeleteSessionInput!): String!
|
cleanupCopilotSession(options: DeleteSessionInput!): [String!]!
|
||||||
|
|
||||||
"""Create a subscription checkout link of stripe"""
|
"""Create a subscription checkout link of stripe"""
|
||||||
createCheckoutSession(input: CreateCheckoutSessionInput!): String!
|
createCheckoutSession(input: CreateCheckoutSessionInput!): String!
|
||||||
|
|||||||
Reference in New Issue
Block a user