2022-01-11 13:51:48 +00:00
|
|
|
import Model from '@nozbe/watermelondb/Model';
|
|
|
|
import { MarkdownAST } from '@rocket.chat/message-parser';
|
|
|
|
|
2022-04-07 14:10:03 +00:00
|
|
|
import { MessageTypeLoad } from '../lib/constants';
|
2022-01-11 13:51:48 +00:00
|
|
|
import { IAttachment } from './IAttachment';
|
|
|
|
import { IReaction } from './IReaction';
|
2022-11-29 18:06:04 +00:00
|
|
|
import { IThreadMessage } from './IThreadMessage';
|
|
|
|
import { IThread } from './IThread';
|
2022-04-01 21:52:38 +00:00
|
|
|
import { IUrl, IUrlFromServer } from './IUrl';
|
2022-02-16 21:14:28 +00:00
|
|
|
|
2022-11-25 13:57:50 +00:00
|
|
|
export type MessageType =
|
|
|
|
| 'jitsi_call_started'
|
|
|
|
| 'discussion-created'
|
|
|
|
| 'e2e'
|
|
|
|
| 'rm'
|
|
|
|
| 'uj'
|
|
|
|
| MessageTypeLoad
|
|
|
|
| MessageTypesValues;
|
2022-01-11 13:51:48 +00:00
|
|
|
|
|
|
|
export interface IUserMessage {
|
|
|
|
_id: string;
|
|
|
|
username?: string;
|
|
|
|
name?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IUserMention extends IUserMessage {
|
|
|
|
type: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IUserChannel {
|
|
|
|
[index: number]: string | number;
|
|
|
|
name: string;
|
|
|
|
_id: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IEditedBy {
|
|
|
|
_id: string;
|
|
|
|
username: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type TOnLinkPress = (link: string) => void;
|
|
|
|
|
|
|
|
export interface ITranslations {
|
|
|
|
_id: string;
|
|
|
|
language: string;
|
|
|
|
value: string;
|
|
|
|
}
|
|
|
|
|
2022-02-16 21:14:28 +00:00
|
|
|
export type E2EType = 'pending' | 'done';
|
|
|
|
|
2022-01-11 13:51:48 +00:00
|
|
|
export interface ILastMessage {
|
2022-04-20 21:37:54 +00:00
|
|
|
_id?: string;
|
|
|
|
rid?: string;
|
2022-03-08 02:54:34 +00:00
|
|
|
tshow?: boolean;
|
|
|
|
t?: MessageType;
|
|
|
|
tmid?: string;
|
|
|
|
msg?: string;
|
|
|
|
e2e?: E2EType;
|
2022-04-20 21:37:54 +00:00
|
|
|
ts?: string | Date;
|
2022-01-11 13:51:48 +00:00
|
|
|
u: IUserMessage;
|
2022-04-20 21:37:54 +00:00
|
|
|
_updatedAt?: string | Date;
|
2022-03-08 02:54:34 +00:00
|
|
|
urls?: IUrlFromServer[];
|
|
|
|
mentions?: IUserMention[];
|
|
|
|
channels?: IUserChannel[];
|
|
|
|
md?: MarkdownAST;
|
|
|
|
attachments?: IAttachment[];
|
|
|
|
reactions?: IReaction[];
|
|
|
|
unread?: boolean;
|
2022-04-20 21:37:54 +00:00
|
|
|
pinned?: boolean;
|
2022-03-08 02:54:34 +00:00
|
|
|
status?: number;
|
2022-04-20 20:53:11 +00:00
|
|
|
token?: string;
|
2022-01-11 13:51:48 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 21:32:03 +00:00
|
|
|
interface IMessageFile {
|
|
|
|
_id: string;
|
|
|
|
name: string;
|
|
|
|
type: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IMessageFromServer {
|
|
|
|
_id: string;
|
|
|
|
rid: string;
|
2022-03-08 02:54:34 +00:00
|
|
|
msg?: string;
|
2022-02-25 21:32:03 +00:00
|
|
|
ts: string | Date; // wm date issue
|
|
|
|
u: IUserMessage;
|
|
|
|
_updatedAt: string | Date;
|
2022-04-01 21:52:38 +00:00
|
|
|
urls?: IUrl[];
|
2022-03-08 02:54:34 +00:00
|
|
|
mentions?: IUserMention[];
|
|
|
|
channels?: IUserChannel[];
|
|
|
|
md?: MarkdownAST;
|
|
|
|
file?: IMessageFile;
|
|
|
|
files?: IMessageFile[];
|
|
|
|
groupable?: boolean;
|
|
|
|
attachments?: IAttachment[];
|
2022-03-08 17:09:45 +00:00
|
|
|
t?: MessageType;
|
|
|
|
drid?: string;
|
|
|
|
dcount?: number;
|
|
|
|
dml: string | Date;
|
2022-05-11 02:22:17 +00:00
|
|
|
starred?: boolean;
|
2022-03-10 15:00:50 +00:00
|
|
|
pinned?: boolean;
|
|
|
|
pinnedAt?: string | Date;
|
|
|
|
pinnedBy?: {
|
|
|
|
_id: string;
|
|
|
|
username: string;
|
|
|
|
};
|
2022-03-10 15:17:49 +00:00
|
|
|
score?: number;
|
2022-02-25 21:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ILoadMoreMessage {
|
2022-02-16 15:02:17 +00:00
|
|
|
_id: string;
|
2022-02-16 21:14:28 +00:00
|
|
|
rid: string;
|
2022-02-25 21:32:03 +00:00
|
|
|
ts: string;
|
|
|
|
t: string;
|
|
|
|
msg: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IMessage extends IMessageFromServer {
|
2022-02-22 16:01:35 +00:00
|
|
|
id: string;
|
2022-04-01 21:52:38 +00:00
|
|
|
t: MessageType;
|
2022-02-17 00:07:24 +00:00
|
|
|
alias?: string;
|
|
|
|
parseUrls?: boolean;
|
2022-01-11 13:51:48 +00:00
|
|
|
avatar?: string;
|
|
|
|
emoji?: string;
|
|
|
|
status?: number;
|
|
|
|
pinned?: boolean;
|
|
|
|
editedBy?: IEditedBy;
|
|
|
|
reactions?: IReaction[];
|
|
|
|
role?: string;
|
|
|
|
drid?: string;
|
|
|
|
dcount?: number;
|
2022-02-22 16:01:35 +00:00
|
|
|
dlm?: string | Date;
|
2022-01-11 13:51:48 +00:00
|
|
|
tmid?: string;
|
2022-03-22 14:29:45 +00:00
|
|
|
tcount?: number | null;
|
|
|
|
tlm?: string | Date | null;
|
2022-01-11 13:51:48 +00:00
|
|
|
replies?: string[];
|
|
|
|
unread?: boolean;
|
|
|
|
autoTranslate?: boolean;
|
|
|
|
translations?: ITranslations[];
|
|
|
|
tmsg?: string;
|
|
|
|
blocks?: any;
|
2022-03-08 02:54:34 +00:00
|
|
|
e2e?: E2EType;
|
2022-01-11 13:51:48 +00:00
|
|
|
tshow?: boolean;
|
2022-04-20 20:53:11 +00:00
|
|
|
comment?: string;
|
2022-02-17 00:07:24 +00:00
|
|
|
subscription?: { id: string };
|
2022-05-11 02:22:17 +00:00
|
|
|
user?: string;
|
|
|
|
editedAt?: string | Date;
|
2021-12-03 19:27:57 +00:00
|
|
|
}
|
2022-01-11 13:51:48 +00:00
|
|
|
|
2022-11-29 13:58:57 +00:00
|
|
|
export type TMessageModel = IMessage &
|
|
|
|
Model & {
|
|
|
|
asPlain: () => IMessage;
|
|
|
|
};
|
2022-02-25 21:32:03 +00:00
|
|
|
|
2022-11-29 13:58:57 +00:00
|
|
|
export type TAnyMessage = IMessage | IThread | IThreadMessage;
|
2022-02-25 21:32:03 +00:00
|
|
|
export type TTypeMessages = IMessageFromServer | ILoadMoreMessage | IMessage;
|
2022-03-14 13:32:22 +00:00
|
|
|
|
|
|
|
// Read receipts to ReadReceiptView and chat.getMessageReadReceipts
|
|
|
|
export interface IReadReceipts {
|
|
|
|
_id: string;
|
|
|
|
roomId: string;
|
|
|
|
userId: string;
|
|
|
|
messageId: string;
|
|
|
|
ts: string;
|
|
|
|
user?: IUserMessage;
|
|
|
|
}
|
2022-10-21 16:35:26 +00:00
|
|
|
|
|
|
|
// from Rocket.Chat codebase
|
|
|
|
type VoipMessageTypesValues =
|
|
|
|
| 'voip-call-started'
|
|
|
|
| 'voip-call-declined'
|
|
|
|
| 'voip-call-on-hold'
|
|
|
|
| 'voip-call-unhold'
|
|
|
|
| 'voip-call-ended'
|
|
|
|
| 'voip-call-duration'
|
|
|
|
| 'voip-call-wrapup'
|
|
|
|
| 'voip-call-ended-unexpectedly';
|
|
|
|
|
|
|
|
type TeamMessageTypes =
|
|
|
|
| 'removed-user-from-team'
|
|
|
|
| 'added-user-to-team'
|
|
|
|
| 'ult'
|
|
|
|
| 'user-converted-to-team'
|
|
|
|
| 'user-converted-to-channel'
|
|
|
|
| 'user-removed-room-from-team'
|
|
|
|
| 'user-deleted-room-from-team'
|
|
|
|
| 'user-added-room-to-team'
|
|
|
|
| 'ujt';
|
|
|
|
|
|
|
|
type LivechatMessageTypes =
|
|
|
|
| 'livechat_navigation_history'
|
|
|
|
| 'livechat_transfer_history'
|
|
|
|
| 'livechat_transcript_history'
|
|
|
|
| 'livechat_video_call'
|
|
|
|
| 'livechat_webrtc_video_call'
|
|
|
|
| 'livechat-started';
|
|
|
|
|
|
|
|
type OmnichannelTypesValues =
|
|
|
|
| 'livechat_transfer_history_fallback'
|
|
|
|
| 'livechat-close'
|
|
|
|
| 'omnichannel_placed_chat_on_hold'
|
|
|
|
| 'omnichannel_on_hold_chat_resumed';
|
|
|
|
|
|
|
|
type OtrMessageTypeValues = 'otr' | 'otr-ack';
|
|
|
|
type OtrSystemMessages = 'user_joined_otr' | 'user_requested_otr_key_refresh' | 'user_key_refreshed_successfully';
|
|
|
|
|
|
|
|
export type MessageTypesValues =
|
|
|
|
| 'e2e'
|
|
|
|
| 'uj'
|
|
|
|
| 'ul'
|
|
|
|
| 'ru'
|
|
|
|
| 'au'
|
|
|
|
| 'mute_unmute'
|
|
|
|
| 'r'
|
|
|
|
| 'ut'
|
|
|
|
| 'wm'
|
|
|
|
| 'rm'
|
|
|
|
| 'subscription-role-added'
|
|
|
|
| 'subscription-role-removed'
|
|
|
|
| 'room-archived'
|
|
|
|
| 'room-unarchived'
|
|
|
|
| 'room_changed_privacy'
|
|
|
|
| 'room_changed_description'
|
|
|
|
| 'room_changed_announcement'
|
|
|
|
| 'room_changed_avatar'
|
|
|
|
| 'room_changed_topic'
|
|
|
|
| 'room_e2e_enabled'
|
|
|
|
| 'room_e2e_disabled'
|
|
|
|
| 'user-muted'
|
|
|
|
| 'user-unmuted'
|
|
|
|
| 'room-removed-read-only'
|
|
|
|
| 'room-set-read-only'
|
|
|
|
| 'room-allowed-reacting'
|
|
|
|
| 'room-disallowed-reacting'
|
|
|
|
| 'command'
|
2022-11-24 17:24:20 +00:00
|
|
|
| 'videoconf'
|
2022-10-21 16:35:26 +00:00
|
|
|
| LivechatMessageTypes
|
|
|
|
| TeamMessageTypes
|
|
|
|
| VoipMessageTypesValues
|
|
|
|
| OmnichannelTypesValues
|
|
|
|
| OtrMessageTypeValues
|
|
|
|
| OtrSystemMessages
|
|
|
|
| 'message_pinned'
|
|
|
|
| 'message_snippeted'
|
|
|
|
| 'jitsi_call_started';
|