import Model from '@nozbe/watermelondb/Model';
import { MarkdownAST } from '@rocket.chat/message-parser';
import { MessageTypeLoad } from '../lib/constants';
import { IAttachment } from './IAttachment';
import { IReaction } from './IReaction';
import { TThreadMessageModel } from './IThreadMessage';
import { TThreadModel } from './IThread';
import { IUrl, IUrlFromServer } from './IUrl';
export type MessageType = 'jitsi_call_started' | 'discussion-created' | 'e2e' | 'load_more' | 'rm' | 'uj' | MessageTypeLoad;
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;
export interface IEditedBy {
username: string;
export type TOnLinkPress = (link: string) => void;
export interface ITranslations {
language: string;
value: string;
export type E2EType = 'pending' | 'done';
export interface ILastMessage {
_id?: string;
rid?: string;
tshow?: boolean;
t?: MessageType;
tmid?: string;
msg?: string;
e2e?: E2EType;
ts?: string | Date;
u: IUserMessage;
_updatedAt?: string | Date;
urls?: IUrlFromServer[];
mentions?: IUserMention[];
channels?: IUserChannel[];
md?: MarkdownAST;
attachments?: IAttachment[];
reactions?: IReaction[];
unread?: boolean;
pinned?: boolean;
status?: number;
token?: string;
interface IMessageFile {
export interface IMessageFromServer {
rid: string;
ts: string | Date; // wm date issue
_updatedAt: string | Date;
urls?: IUrl[];
file?: IMessageFile;
files?: IMessageFile[];
groupable?: boolean;
drid?: string;
dcount?: number;
dml: string | Date;
starred?: boolean;
pinnedAt?: string | Date;
pinnedBy?: {
};
score?: number;
export interface ILoadMoreMessage {
ts: string;
t: string;
msg: string;
export interface IMessage extends IMessageFromServer {
id: string;
t: MessageType;
alias?: string;
parseUrls?: boolean;
avatar?: string;
emoji?: string;
editedBy?: IEditedBy;
role?: string;
dlm?: string | Date;
tcount?: number | null;
tlm?: string | Date | null;
replies?: string[];
autoTranslate?: boolean;
translations?: ITranslations[];
tmsg?: string;
blocks?: any;
comment?: string;
subscription?: { id: string };
user?: string;
editedAt?: string | Date;
export type TMessageModel = IMessage & Model;
export type TAnyMessageModel = TMessageModel | TThreadModel | TThreadMessageModel;
export type TTypeMessages = IMessageFromServer | ILoadMoreMessage | IMessage;
// Read receipts to ReadReceiptView and chat.getMessageReadReceipts
export interface IReadReceipts {
roomId: string;
userId: string;
messageId: string;
user?: IUserMessage;