Update environment configuration for production, refactor WebRTC components, and enhance chat functionality. Replace deprecated SessionUsersPanel with SessionPage, integrate chat history loading, and improve audio/video toggle handling. Remove unused SessionUsersPanel2 component and update related socket event handling in the server.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { pgTable, uuid, text, timestamp, pgEnum } from "drizzle-orm/pg-core";
|
||||
import { relations } from "drizzle-orm";
|
||||
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
|
||||
import { serverSessions } from "./serverSessions";
|
||||
import { users } from "./users";
|
||||
|
||||
// Enum для типа сообщения
|
||||
export const messageTypeEnum = pgEnum("message_type", ["text", "system"]);
|
||||
|
||||
export const chatMessages = pgTable("chat_messages", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
sessionId: uuid("session_id")
|
||||
.notNull()
|
||||
.references(() => serverSessions.id, { onDelete: "cascade" }),
|
||||
userId: uuid("user_id").references(() => users.id), // Nullable для системных сообщений или анонимных пользователей
|
||||
content: text("content").notNull(),
|
||||
type: messageTypeEnum("type").notNull().default("text"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true })
|
||||
.defaultNow()
|
||||
.notNull(),
|
||||
});
|
||||
|
||||
// Relations
|
||||
export const chatMessagesRelations = relations(chatMessages, ({ one }) => ({
|
||||
session: one(serverSessions, {
|
||||
fields: [chatMessages.sessionId],
|
||||
references: [serverSessions.id],
|
||||
}),
|
||||
user: one(users, {
|
||||
fields: [chatMessages.userId],
|
||||
references: [users.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
// Zod schemas for validation
|
||||
export const insertChatMessageSchema = createInsertSchema(chatMessages);
|
||||
export const selectChatMessageSchema = createSelectSchema(chatMessages);
|
||||
|
||||
// Type exports
|
||||
export type ChatMessage = typeof chatMessages.$inferSelect;
|
||||
export type NewChatMessage = typeof chatMessages.$inferInsert;
|
||||
|
||||
@@ -9,6 +9,7 @@ export * from "./userBranches";
|
||||
export * from "./serverSessions";
|
||||
export * from "./authSessions";
|
||||
export * from "./protectedRoutes";
|
||||
export * from "./chatMessages";
|
||||
|
||||
// Relations (defined here to avoid circular dependencies)
|
||||
import { relations } from "drizzle-orm";
|
||||
|
||||
Reference in New Issue
Block a user