2022-01-11 13:51:48 +00:00
|
|
|
import Model from '@nozbe/watermelondb/Model';
|
|
|
|
import { MarkdownAST } from '@rocket.chat/message-parser';
|
|
|
|
|
|
|
|
import { IAttachment } from './IAttachment';
|
|
|
|
import { IReaction } from './IReaction';
|
2022-02-25 21:32:03 +00:00
|
|
|
import { IUrlFromServer } from './IUrl';
|
2022-02-16 21:14:28 +00:00
|
|
|
|
|
|
|
export type MessageType = 'jitsi_call_started' | 'discussion-created' | 'e2e' | 'load_more' | 'rm' | 'uj';
|
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 {
|
|
|
|
_id: string;
|
|
|
|
rid: string;
|
|
|
|
tshow: boolean;
|
2022-02-16 21:14:28 +00:00
|
|
|
t: MessageType;
|
2022-01-11 13:51:48 +00:00
|
|
|
tmid: string;
|
2021-12-03 19:27:57 +00:00
|
|
|
msg: string;
|
2022-02-16 21:14:28 +00:00
|
|
|
e2e: E2EType;
|
2022-01-11 13:51:48 +00:00
|
|
|
ts: Date;
|
|
|
|
u: IUserMessage;
|
|
|
|
_updatedAt: Date;
|
|
|
|
urls: string[];
|
|
|
|
mentions: IUserMention[];
|
|
|
|
channels: IUserChannel[];
|
|
|
|
md: MarkdownAST;
|
|
|
|
attachments: IAttachment[];
|
|
|
|
reactions: IReaction[];
|
|
|
|
unread: boolean;
|
|
|
|
status: boolean;
|
|
|
|
}
|
|
|
|
|
2022-02-25 21:32:03 +00:00
|
|
|
interface IMessageFile {
|
|
|
|
_id: string;
|
|
|
|
name: string;
|
|
|
|
type: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IMessageAttachment {
|
|
|
|
ts: string;
|
|
|
|
title: string;
|
|
|
|
title_link: string;
|
|
|
|
title_link_download: true;
|
|
|
|
image_dimensions: {
|
|
|
|
width: number;
|
|
|
|
height: number;
|
|
|
|
};
|
|
|
|
image_preview: string;
|
|
|
|
image_url: string;
|
|
|
|
image_type: string;
|
|
|
|
image_size: number;
|
|
|
|
type: string;
|
|
|
|
description: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IMessageFromServer {
|
|
|
|
_id: string;
|
|
|
|
rid: string;
|
|
|
|
msg: string;
|
|
|
|
ts: string | Date; // wm date issue
|
|
|
|
u: IUserMessage;
|
|
|
|
_updatedAt: string | Date;
|
|
|
|
urls: IUrlFromServer[];
|
|
|
|
mentions: IUserMention[];
|
|
|
|
channels: IUserChannel[];
|
|
|
|
md: MarkdownAST;
|
|
|
|
file: IMessageFile;
|
|
|
|
files: IMessageFile[];
|
|
|
|
groupable: false;
|
|
|
|
attachments: IMessageAttachment[];
|
|
|
|
}
|
|
|
|
|
|
|
|
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-02-16 21:14:28 +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;
|
|
|
|
starred?: 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;
|
|
|
|
tcount?: number;
|
2022-02-22 16:01:35 +00:00
|
|
|
tlm?: string | Date;
|
2022-01-11 13:51:48 +00:00
|
|
|
replies?: string[];
|
|
|
|
unread?: boolean;
|
|
|
|
autoTranslate?: boolean;
|
|
|
|
translations?: ITranslations[];
|
|
|
|
tmsg?: string;
|
|
|
|
blocks?: any;
|
|
|
|
e2e?: string;
|
|
|
|
tshow?: boolean;
|
2022-02-17 00:07:24 +00:00
|
|
|
subscription?: { id: string };
|
2021-12-03 19:27:57 +00:00
|
|
|
}
|
2022-01-11 13:51:48 +00:00
|
|
|
|
|
|
|
export type TMessageModel = IMessage & Model;
|
2022-02-25 21:32:03 +00:00
|
|
|
|
|
|
|
export type TTypeMessages = IMessageFromServer | ILoadMoreMessage | IMessage;
|