2022-01-11 13:51:48 +00:00
|
|
|
import Model from '@nozbe/watermelondb/Model';
|
|
|
|
import Relation from '@nozbe/watermelondb/Relation';
|
|
|
|
|
|
|
|
import { ILastMessage, TMessageModel } from './IMessage';
|
2022-03-08 16:25:27 +00:00
|
|
|
import { IRocketChatRecord } from './IRocketChatRecord';
|
2022-04-15 02:27:36 +00:00
|
|
|
import { IOmnichannelSource, RoomID, RoomType } from './IRoom';
|
2022-01-11 13:51:48 +00:00
|
|
|
import { IServedBy } from './IServedBy';
|
|
|
|
import { TThreadModel } from './IThread';
|
|
|
|
import { TThreadMessageModel } from './IThreadMessage';
|
|
|
|
import { TUploadModel } from './IUpload';
|
2022-03-08 16:25:27 +00:00
|
|
|
import { IUser } from './IUser';
|
2022-01-11 13:51:48 +00:00
|
|
|
|
|
|
|
export enum SubscriptionType {
|
|
|
|
GROUP = 'p',
|
|
|
|
DIRECT = 'd',
|
|
|
|
CHANNEL = 'c',
|
|
|
|
OMNICHANNEL = 'l',
|
2022-03-02 14:49:43 +00:00
|
|
|
E2E = 'e2e', // FIXME: this is not a type of subscription
|
2022-02-15 18:50:55 +00:00
|
|
|
THREAD = 'thread' // FIXME: this is not a type of subscription
|
2022-01-11 13:51:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface IVisitor {
|
2022-03-07 21:16:20 +00:00
|
|
|
_id?: string;
|
|
|
|
token?: string;
|
|
|
|
status: 'online' | 'busy' | 'away' | 'offline';
|
|
|
|
username?: string;
|
|
|
|
lastMessageTs?: Date;
|
2022-01-11 13:51:48 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 20:00:33 +00:00
|
|
|
export enum ERoomTypes {
|
|
|
|
DIRECT = 'direct',
|
|
|
|
GROUP = 'group',
|
|
|
|
CHANNEL = 'channel'
|
|
|
|
}
|
|
|
|
|
2022-03-03 20:25:03 +00:00
|
|
|
type RelationModified<T extends Model> = { fetch(): Promise<T[]> } & Relation<T>;
|
|
|
|
|
2022-01-11 13:51:48 +00:00
|
|
|
export interface ISubscription {
|
2022-03-08 16:25:27 +00:00
|
|
|
_id: string;
|
|
|
|
id: string;
|
|
|
|
_updatedAt?: string;
|
2022-02-21 19:41:49 +00:00
|
|
|
v?: IVisitor;
|
2022-01-11 13:51:48 +00:00
|
|
|
f: boolean;
|
2022-03-03 21:46:53 +00:00
|
|
|
t: SubscriptionType; // TODO: we need to review this type later
|
2022-02-22 16:01:35 +00:00
|
|
|
ts: string | Date;
|
2022-01-11 13:51:48 +00:00
|
|
|
ls: Date;
|
|
|
|
name: string;
|
|
|
|
fname?: string;
|
2023-05-29 15:03:24 +00:00
|
|
|
sanitizedFname?: string;
|
2022-01-11 13:51:48 +00:00
|
|
|
rid: string; // the same as id
|
|
|
|
open: boolean;
|
|
|
|
alert: boolean;
|
|
|
|
roles?: string[];
|
|
|
|
unread: number;
|
2022-02-21 19:41:49 +00:00
|
|
|
lm: string;
|
|
|
|
lr: string;
|
2022-01-11 13:51:48 +00:00
|
|
|
userMentions: number;
|
|
|
|
groupMentions: number;
|
2022-02-25 18:59:39 +00:00
|
|
|
tunread: string[];
|
2022-01-11 13:51:48 +00:00
|
|
|
tunreadUser?: string[];
|
|
|
|
tunreadGroup?: string[];
|
2022-02-21 19:41:49 +00:00
|
|
|
roomUpdatedAt: Date | number;
|
2022-01-11 13:51:48 +00:00
|
|
|
ro: boolean;
|
|
|
|
lastOpen?: Date;
|
|
|
|
description?: string;
|
|
|
|
announcement?: string;
|
|
|
|
bannerClosed?: boolean;
|
|
|
|
topic?: string;
|
|
|
|
blocked?: boolean;
|
|
|
|
blocker?: boolean;
|
|
|
|
reactWhenReadOnly?: boolean;
|
|
|
|
archived: boolean;
|
|
|
|
joinCodeRequired?: boolean;
|
|
|
|
muted?: string[];
|
2023-11-17 18:48:32 +00:00
|
|
|
unmuted?: string[];
|
2022-01-11 13:51:48 +00:00
|
|
|
ignored?: string[];
|
|
|
|
broadcast?: boolean;
|
|
|
|
prid?: string;
|
2022-02-22 12:04:01 +00:00
|
|
|
draftMessage?: string | null;
|
2022-01-11 13:51:48 +00:00
|
|
|
lastThreadSync?: Date;
|
2022-03-08 16:25:27 +00:00
|
|
|
jitsiTimeout?: Date;
|
2022-01-11 13:51:48 +00:00
|
|
|
autoTranslate?: boolean;
|
2022-03-02 14:18:01 +00:00
|
|
|
autoTranslateLanguage?: string;
|
2022-03-08 02:54:34 +00:00
|
|
|
lastMessage?: ILastMessage | null; // TODO: we need to use IMessage here
|
2022-01-11 13:51:48 +00:00
|
|
|
hideUnreadStatus?: boolean;
|
|
|
|
sysMes?: string[] | boolean;
|
|
|
|
uids?: string[];
|
|
|
|
usernames?: string[];
|
|
|
|
visitor?: IVisitor;
|
|
|
|
departmentId?: string;
|
2022-03-02 14:49:43 +00:00
|
|
|
status?: string;
|
2022-01-11 13:51:48 +00:00
|
|
|
servedBy?: IServedBy;
|
|
|
|
livechatData?: any;
|
|
|
|
tags?: string[];
|
|
|
|
E2EKey?: string;
|
2023-01-12 13:32:33 +00:00
|
|
|
E2ESuggestedKey?: string;
|
2022-01-11 13:51:48 +00:00
|
|
|
encrypted?: boolean;
|
|
|
|
e2eKeyId?: string;
|
|
|
|
avatarETag?: string;
|
|
|
|
teamId?: string;
|
|
|
|
teamMain?: boolean;
|
2022-03-04 00:49:20 +00:00
|
|
|
unsubscribe: () => Promise<any>;
|
2022-02-25 18:59:39 +00:00
|
|
|
separator?: boolean;
|
2022-04-20 20:53:11 +00:00
|
|
|
onHold?: boolean;
|
2022-04-15 02:27:36 +00:00
|
|
|
source?: IOmnichannelSource;
|
2022-06-13 13:24:54 +00:00
|
|
|
hideMentionStatus?: boolean;
|
2023-04-28 15:16:14 +00:00
|
|
|
usersCount?: number;
|
2022-01-11 13:51:48 +00:00
|
|
|
// https://nozbe.github.io/WatermelonDB/Relation.html#relation-api
|
2022-03-03 20:25:03 +00:00
|
|
|
messages: RelationModified<TMessageModel>;
|
|
|
|
threads: RelationModified<TThreadModel>;
|
|
|
|
threadMessages: RelationModified<TThreadMessageModel>;
|
|
|
|
uploads: RelationModified<TUploadModel>;
|
2024-03-04 11:27:24 +00:00
|
|
|
disableNotifications?: boolean;
|
2022-01-11 13:51:48 +00:00
|
|
|
}
|
|
|
|
|
2023-11-17 18:48:32 +00:00
|
|
|
export type TSubscriptionModel = ISubscription &
|
|
|
|
Model & {
|
|
|
|
asPlain: () => ISubscription;
|
|
|
|
};
|
2022-04-04 19:15:29 +00:00
|
|
|
export type TSubscription = TSubscriptionModel | ISubscription;
|
2022-02-21 19:41:49 +00:00
|
|
|
|
2022-03-08 16:25:27 +00:00
|
|
|
// https://github.com/RocketChat/Rocket.Chat/blob/a88a96fcadd925b678ff27ada37075e029f78b5e/definition/ISubscription.ts#L8
|
|
|
|
export interface IServerSubscription extends IRocketChatRecord {
|
|
|
|
u: Pick<IUser, '_id' | 'username' | 'name'>;
|
|
|
|
v?: Pick<IUser, '_id' | 'username' | 'name'>;
|
|
|
|
rid: RoomID;
|
2022-02-21 19:41:49 +00:00
|
|
|
open: boolean;
|
2022-03-08 16:25:27 +00:00
|
|
|
ts: Date;
|
|
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
alert?: boolean;
|
2022-02-21 19:41:49 +00:00
|
|
|
unread: number;
|
2022-03-08 16:25:27 +00:00
|
|
|
t: RoomType;
|
|
|
|
ls: Date;
|
|
|
|
f?: true;
|
|
|
|
lr: Date;
|
|
|
|
hideUnreadStatus?: true;
|
|
|
|
teamMain?: boolean;
|
|
|
|
teamId?: string;
|
|
|
|
|
2022-02-21 19:41:49 +00:00
|
|
|
userMentions: number;
|
2022-03-08 16:25:27 +00:00
|
|
|
groupMentions: number;
|
|
|
|
|
|
|
|
tunread?: Array<string>;
|
|
|
|
tunreadGroup?: Array<string>;
|
|
|
|
tunreadUser?: Array<string>;
|
|
|
|
|
|
|
|
prid?: RoomID;
|
|
|
|
|
|
|
|
roles?: string[];
|
|
|
|
|
|
|
|
onHold?: boolean;
|
|
|
|
encrypted?: boolean;
|
|
|
|
E2EKey?: string;
|
2023-01-12 13:32:33 +00:00
|
|
|
E2ESuggestedKey?: string;
|
2022-03-08 16:25:27 +00:00
|
|
|
unreadAlert?: 'default' | 'all' | 'mentions' | 'nothing';
|
|
|
|
|
|
|
|
fname?: unknown;
|
|
|
|
|
|
|
|
code?: unknown;
|
|
|
|
archived?: unknown;
|
|
|
|
audioNotificationValue?: unknown;
|
|
|
|
desktopNotifications?: unknown;
|
|
|
|
mobilePushNotifications?: unknown;
|
|
|
|
emailNotifications?: unknown;
|
|
|
|
blocked?: unknown;
|
|
|
|
blocker?: unknown;
|
|
|
|
autoTranslate?: unknown;
|
|
|
|
autoTranslateLanguage?: unknown;
|
|
|
|
disableNotifications?: unknown;
|
|
|
|
muteGroupMentions?: unknown;
|
|
|
|
ignored?: unknown;
|
2022-02-21 19:41:49 +00:00
|
|
|
|
2022-03-08 16:25:27 +00:00
|
|
|
department?: unknown;
|
2022-02-21 19:41:49 +00:00
|
|
|
}
|