Created
September 30, 2024 09:34
-
-
Save PhantomKnight287/9e5351fbd2e10634659f70f666a4e36e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import {randomBytes} from "crypto" | |
| async createChat(userId: string, body: CreateChatDTO) { | |
| const key = randomBytes(32).toString('base64'); | |
| const iv = randomBytes(16).toString('base64'); | |
| const chat = await prisma.chat.create({ | |
| data: { | |
| id: `ch_${createId()}`, | |
| name: body.name, | |
| topic: body.topic, | |
| members: { | |
| create: { | |
| id: `cm_${createId()}`, | |
| role: 'Owner', | |
| userId, | |
| }, | |
| }, | |
| }, | |
| }); | |
| return { | |
| ...chat, | |
| key: key, | |
| iv: iv, | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment