mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
948 B
TypeScript
57 lines
948 B
TypeScript
import { request } from '../api/request';
|
|
|
|
export interface ChatMessage {
|
|
_id: string;
|
|
|
|
content: string;
|
|
|
|
author?: string;
|
|
|
|
groupId?: string;
|
|
|
|
converseId: string;
|
|
|
|
reactions?: any[];
|
|
|
|
createdAt?: string;
|
|
|
|
updatedAt?: string;
|
|
}
|
|
|
|
export interface SendMessagePayload {
|
|
groupId?: string;
|
|
converseId: string;
|
|
content: string;
|
|
}
|
|
|
|
/**
|
|
* 获取会话消息
|
|
* @param converseId 会话ID
|
|
* @param startId 开始ID
|
|
*/
|
|
export async function fetchConverseMessage(
|
|
converseId: string,
|
|
startId?: string
|
|
): Promise<ChatMessage[]> {
|
|
const { data } = await request.get('/api/chat/message/fetchConverseMessage', {
|
|
params: {
|
|
converseId,
|
|
startId,
|
|
},
|
|
});
|
|
|
|
return data;
|
|
}
|
|
|
|
/**
|
|
* 发送消息
|
|
* @param payload 消息体
|
|
*/
|
|
export async function sendMessage(
|
|
payload: SendMessagePayload
|
|
): Promise<ChatMessage> {
|
|
const { data } = await request.post('/api/chat/message/sendMessage', payload);
|
|
|
|
return data;
|
|
}
|