Files
knowai/types/chat/base.ts
2025-11-23 22:26:39 +08:00

48 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { User } from '../index';
import type { ChatMessageType, ChatMessageStatus } from './enum';
// 聊天消息接口
export interface ChatMessage {
id: string;
// 聊天会话id下面那个接口的id
sessionId: string;
sender: User;
receiver: User;
content: string;
type: ChatMessageType;
status: ChatMessageStatus;
createdAt: Date;
// 非文本消息类型的元数据
metadata?: {
fileName?: string;
fileSize?: number;
duration?: number;
// 小图预览
thumbnail?: string;
[key: string]: unknown;
};
}
// 聊天会话接口
export interface ChatSession {
id: string;
participant1Id: string;
participant2Id: string;
participant1: User;
participant2: User;
lastMessage?: {
id: string;
content: string;
senderId: string;
createdAt: Date;
};
unreadCount1: number; // 参与者1的未读消息数
unreadCount2: number; // 参与者2的未读消息数
createdAt: Date;
updatedAt: Date;
// 会话元数据(特殊标记、背景设置、自定义属性等等)
metadata?: {
[key: string]: unknown;
};
}