2022-03-14 13:32:22 +00:00
|
|
|
import type { IMessage, IMessageFromServer, IReadReceipts } from '../../IMessage';
|
2022-03-08 16:25:27 +00:00
|
|
|
import type { IServerRoom } from '../../IRoom';
|
2022-02-15 18:50:55 +00:00
|
|
|
import { PaginatedResult } from '../helpers/PaginatedResult';
|
2022-02-14 16:20:29 +00:00
|
|
|
|
|
|
|
export type ChatEndpoints = {
|
|
|
|
'chat.getMessage': {
|
|
|
|
GET: (params: { msgId: IMessage['_id'] }) => {
|
|
|
|
message: IMessage;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
'chat.followMessage': {
|
|
|
|
POST: (params: { mid: IMessage['_id'] }) => void;
|
|
|
|
};
|
2022-03-05 03:08:26 +00:00
|
|
|
'chat.unStarMessage': {
|
|
|
|
POST: (params: { messageId: IMessage['_id'] }) => void;
|
|
|
|
};
|
|
|
|
'chat.starMessage': {
|
|
|
|
POST: (params: { messageId: IMessage['_id'] }) => void;
|
|
|
|
};
|
2022-02-14 16:20:29 +00:00
|
|
|
'chat.unfollowMessage': {
|
|
|
|
POST: (params: { mid: IMessage['_id'] }) => void;
|
|
|
|
};
|
2022-03-05 03:17:24 +00:00
|
|
|
'chat.unPinMessage': {
|
|
|
|
POST: (params: { messageId: IMessage['_id'] }) => void;
|
|
|
|
};
|
|
|
|
'chat.pinMessage': {
|
|
|
|
POST: (params: { messageId: IMessage['_id'] }) => void;
|
|
|
|
};
|
2022-03-05 03:40:41 +00:00
|
|
|
'chat.reportMessage': {
|
|
|
|
POST: (params: { messageId: IMessage['_id']; description: string }) => void;
|
|
|
|
};
|
2022-02-14 16:20:29 +00:00
|
|
|
'chat.getDiscussions': {
|
2022-03-08 16:25:27 +00:00
|
|
|
GET: (params: { roomId: IServerRoom['_id']; text?: string; offset: number; count: number }) => {
|
2022-03-08 17:09:45 +00:00
|
|
|
messages: IMessageFromServer[];
|
2022-02-14 16:20:29 +00:00
|
|
|
total: number;
|
2023-03-16 23:30:58 +00:00
|
|
|
count: number;
|
2022-02-14 16:20:29 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
'chat.getThreadsList': {
|
2022-02-15 18:50:55 +00:00
|
|
|
GET: (params: {
|
2022-03-08 16:25:27 +00:00
|
|
|
rid: IServerRoom['_id'];
|
2022-03-17 02:24:22 +00:00
|
|
|
type?: 'unread' | 'following' | 'all';
|
2022-02-15 18:50:55 +00:00
|
|
|
text?: string;
|
|
|
|
offset: number;
|
|
|
|
count: number;
|
|
|
|
}) => PaginatedResult<{
|
2022-02-14 16:20:29 +00:00
|
|
|
threads: IMessage[];
|
|
|
|
total: number;
|
2022-02-15 18:50:55 +00:00
|
|
|
}>;
|
2022-02-14 16:20:29 +00:00
|
|
|
};
|
2022-03-16 01:25:48 +00:00
|
|
|
'chat.syncThreadsList': {
|
|
|
|
GET: (params: { rid: IServerRoom['_id']; updatedSince: string }) => {
|
|
|
|
threads: {
|
|
|
|
update: IMessage[];
|
|
|
|
remove: IMessage[];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-03-02 21:45:05 +00:00
|
|
|
'chat.delete': {
|
|
|
|
POST: (params: { msgId: string; roomId: string }) => {
|
|
|
|
_id: string;
|
|
|
|
ts: string;
|
|
|
|
message: Pick<IMessage, '_id' | 'rid' | 'u'>;
|
|
|
|
};
|
|
|
|
};
|
2022-03-05 03:28:36 +00:00
|
|
|
'chat.react': {
|
|
|
|
POST: (params: { emoji: string; messageId: string }) => void;
|
|
|
|
};
|
2022-03-07 14:08:45 +00:00
|
|
|
'chat.ignoreUser': {
|
|
|
|
GET: (params: { rid: string; userId: string; ignore: boolean }) => {};
|
|
|
|
};
|
2022-03-10 15:17:49 +00:00
|
|
|
'chat.search': {
|
|
|
|
GET: (params: { roomId: IServerRoom['_id']; searchText: string; count: number; offset: number }) => {
|
|
|
|
messages: IMessageFromServer[];
|
|
|
|
};
|
|
|
|
};
|
2022-03-14 14:18:53 +00:00
|
|
|
'chat.update': {
|
|
|
|
POST: (params: { roomId: IServerRoom['_id']; msgId: string; text: string }) => {
|
|
|
|
messages: IMessageFromServer;
|
|
|
|
};
|
|
|
|
};
|
2022-03-14 13:32:22 +00:00
|
|
|
'chat.getMessageReadReceipts': {
|
|
|
|
GET: (params: { messageId: string }) => { receipts: IReadReceipts[] };
|
|
|
|
};
|
2023-08-04 14:09:36 +00:00
|
|
|
'chat.postMessage': {
|
|
|
|
POST: (params: { roomId: string; text: string }) => {
|
|
|
|
message: IMessage;
|
|
|
|
success: boolean;
|
|
|
|
};
|
|
|
|
};
|
2022-02-14 16:20:29 +00:00
|
|
|
};
|