global update and global fix

This commit is contained in:
lendry
2026-06-25 23:48:57 +03:00
parent 3880c68d59
commit b0ea87e898
121 changed files with 13759 additions and 663 deletions

View File

@@ -49,6 +49,9 @@ model User {
birthDate DateTime?
gender String?
isSuperAdmin Boolean @default(false)
isSystemAccount Boolean @default(false)
linkedBotId String? @unique
e2ePublicKey String?
isVerified Boolean @default(false)
verificationIcon String?
verifiedAt DateTime?
@@ -80,6 +83,8 @@ model User {
chatPollVotes ChatPollVote[]
totpSecret UserTotpSecret?
createdOAuthClients OAuthClient[] @relation("OAuthClientCreator")
ownedBots Bot[] @relation("BotOwner")
linkedBot Bot? @relation("BotSystemUser", fields: [linkedBotId], references: [id], onDelete: SetNull)
}
model UserTotpSecret {
@@ -391,6 +396,9 @@ model ChatRoom {
groupId String
type String
name String
peerUserId String?
botUsername String?
isE2E Boolean @default(false)
avatarStorageKey String?
hasAvatar Boolean @default(false)
createdById String?
@@ -401,6 +409,7 @@ model ChatRoom {
messages ChatMessage[]
@@index([groupId, type])
@@index([groupId, type, peerUserId])
}
model ChatRoomMember {
@@ -418,18 +427,19 @@ model ChatRoomMember {
}
model ChatMessage {
id String @id @default(uuid())
roomId String
senderId String
type String
content String?
replyToId String?
metadata Json?
storageKey String?
mimeType String?
createdAt DateTime @default(now())
editedAt DateTime?
deletedAt DateTime?
id String @id @default(uuid())
roomId String
senderId String
type String
content String?
isEncrypted Boolean @default(false)
replyToId String?
metadata Json?
storageKey String?
mimeType String?
createdAt DateTime @default(now())
editedAt DateTime?
deletedAt DateTime?
room ChatRoom @relation(fields: [roomId], references: [id], onDelete: Cascade)
sender User @relation(fields: [senderId], references: [id], onDelete: Cascade)
poll ChatPoll?
@@ -516,3 +526,115 @@ model SocialProvider {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Bot {
id String @id @default(uuid())
name String
username String @unique
tokenHash String @unique
tokenPrefix String
ownerId String
description String?
aboutText String?
botPicUrl String?
menuButton Json?
webAppUrl String?
webhookUrl String?
webhookSecretToken String?
isActive Boolean @default(true)
isSystemBot Boolean @default(false)
nextMessageId Int @default(1)
nextUpdateId Int @default(1)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
owner User @relation("BotOwner", fields: [ownerId], references: [id], onDelete: Cascade)
linkedSystemUser User? @relation("BotSystemUser")
chats BotChat[]
messages BotMessage[]
inboundMessages BotInboundMessage[]
updates BotUpdate[]
chatMenuButtons ChatMenuButton[]
@@index([ownerId])
@@index([tokenHash])
@@index([isActive])
}
model BotChat {
id String @id @default(uuid())
botId String
recipientUserId String?
telegramChatId BigInt
chatType String @default("private")
nextInboundMessageId Int @default(1)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
bot Bot @relation(fields: [botId], references: [id], onDelete: Cascade)
messages BotMessage[]
inboundMessages BotInboundMessage[]
menuButton ChatMenuButton?
@@unique([botId, recipientUserId])
@@unique([botId, telegramChatId])
@@index([botId])
}
model ChatMenuButton {
id String @id @default(uuid())
botId String
botChatId String @unique
menuButton Json
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
bot Bot @relation(fields: [botId], references: [id], onDelete: Cascade)
botChat BotChat @relation(fields: [botChatId], references: [id], onDelete: Cascade)
@@unique([botId, botChatId])
@@index([botId])
}
model BotMessage {
id String @id @default(uuid())
botId String
botChatId String
telegramMsgId Int
messageType String @default("text")
text String?
mediaUrl String?
payload Json?
createdAt DateTime @default(now())
editedAt DateTime?
bot Bot @relation(fields: [botId], references: [id], onDelete: Cascade)
botChat BotChat @relation(fields: [botChatId], references: [id], onDelete: Cascade)
@@unique([botId, telegramMsgId])
@@index([botChatId])
}
model BotInboundMessage {
id String @id @default(uuid())
botId String
botChatId String
senderUserId String
telegramMsgId Int
text String?
payload Json?
createdAt DateTime @default(now())
bot Bot @relation(fields: [botId], references: [id], onDelete: Cascade)
botChat BotChat @relation(fields: [botChatId], references: [id], onDelete: Cascade)
@@unique([botChatId, telegramMsgId])
@@index([botId, createdAt])
}
model BotUpdate {
id String @id @default(uuid())
botId String
updateId Int
payload Json
createdAt DateTime @default(now())
bot Bot @relation(fields: [botId], references: [id], onDelete: Cascade)
@@unique([botId, updateId])
@@index([botId, updateId])
}