-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from n4ze3m/next
v1.7.1
- Loading branch information
Showing
12 changed files
with
317 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "DialoqbaseSettings" ADD COLUMN "numberOfDocuments" INTEGER NOT NULL DEFAULT 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
server/src/handlers/api/v1/bot/playground/delete.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { FastifyReply, FastifyRequest } from "fastify"; | ||
import { DeleteBotByPlaygroundId } from "./types"; | ||
|
||
export const deleteBotByPlaygroundId = async ( | ||
request: FastifyRequest<DeleteBotByPlaygroundId>, | ||
reply: FastifyReply | ||
) => { | ||
const user = request.user; | ||
const { id } = request.params; | ||
|
||
const prisma = request.server.prisma; | ||
|
||
const isRealOwner = await prisma.botPlayground.findFirst({ | ||
where: { | ||
id, | ||
Bot: { | ||
user_id: user.user_id, | ||
}, | ||
}, | ||
}); | ||
|
||
if (!isRealOwner) { | ||
return reply.status(404).send({ | ||
message: "Playground not found", | ||
}); | ||
} | ||
await prisma.botPlaygroundMessage.deleteMany({ | ||
where: { | ||
botPlaygroundId: id, | ||
}, | ||
}); | ||
|
||
await prisma.botPlayground.delete({ | ||
where: { | ||
id, | ||
}, | ||
}); | ||
|
||
return reply.status(200).send({ | ||
message: "Playground deleted", | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export * from "./post.handler" | ||
export * from "./get.handler" | ||
export * from "./chat.handler" | ||
export * from "./chat.handler" | ||
export * from "./delete.handler" | ||
export * from "./put.handler" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { FastifyReply, FastifyRequest } from "fastify"; | ||
import { UpdateBotPlaygroundTitleById } from "./types"; | ||
|
||
export const updateBotPlaygroundTitleById = async ( | ||
request: FastifyRequest<UpdateBotPlaygroundTitleById>, | ||
reply: FastifyReply | ||
) => { | ||
const user = request.user; | ||
const prisma = request.server.prisma; | ||
|
||
const { title } = request.body; | ||
const { id } = request.params; | ||
|
||
const isRealOwner = await prisma.botPlayground.findFirst({ | ||
where: { | ||
id, | ||
Bot: { | ||
user_id: user.user_id, | ||
}, | ||
}, | ||
}); | ||
|
||
if (!isRealOwner) { | ||
return reply.status(404).send({ | ||
message: "Playground not found", | ||
}); | ||
} | ||
|
||
await prisma.botPlayground.update({ | ||
where: { | ||
id, | ||
}, | ||
data: { | ||
title, | ||
}, | ||
}); | ||
|
||
return reply.status(200).send({ | ||
message: "Playground updated", | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.