mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 21:38:44 +08:00
chore(server): not allow to update action's prompt (#9615)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { randomUUID } from 'node:crypto';
|
import { randomUUID } from 'node:crypto';
|
||||||
|
|
||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
import { AiPromptRole, PrismaClient } from '@prisma/client';
|
import { AiPromptRole, Prisma, PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CopilotActionTaken,
|
CopilotActionTaken,
|
||||||
@@ -203,7 +203,8 @@ export class ChatSessionService {
|
|||||||
private async haveSession(
|
private async haveSession(
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
userId: string,
|
userId: string,
|
||||||
tx?: PrismaTransaction
|
tx?: PrismaTransaction,
|
||||||
|
params?: Prisma.AiSessionCountArgs['where']
|
||||||
) {
|
) {
|
||||||
const executor = tx ?? this.db;
|
const executor = tx ?? this.db;
|
||||||
return await executor.aiSession
|
return await executor.aiSession
|
||||||
@@ -211,6 +212,7 @@ export class ChatSessionService {
|
|||||||
where: {
|
where: {
|
||||||
id: sessionId,
|
id: sessionId,
|
||||||
userId,
|
userId,
|
||||||
|
...params,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(c => c > 0);
|
.then(c => c > 0);
|
||||||
@@ -590,7 +592,12 @@ export class ChatSessionService {
|
|||||||
}
|
}
|
||||||
return await this.db.$transaction(async tx => {
|
return await this.db.$transaction(async tx => {
|
||||||
let sessionId = options.sessionId;
|
let sessionId = options.sessionId;
|
||||||
const haveSession = await this.haveSession(sessionId, options.userId, tx);
|
const haveSession = await this.haveSession(
|
||||||
|
sessionId,
|
||||||
|
options.userId,
|
||||||
|
tx,
|
||||||
|
{ prompt: { action: null } }
|
||||||
|
);
|
||||||
if (haveSession) {
|
if (haveSession) {
|
||||||
await tx.aiSession.update({
|
await tx.aiSession.update({
|
||||||
where: { id: sessionId },
|
where: { id: sessionId },
|
||||||
|
|||||||
Reference in New Issue
Block a user