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';
|
|
|
|
import { IServedBy } from './IServedBy';
|
|
|
|
import { TThreadModel } from './IThread';
|
|
|
|
import { TThreadMessageModel } from './IThreadMessage';
|
|
|
|
import { TUploadModel } from './IUpload';
|
|
|
|
|
|
|
|
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 {
|
|
|
|
_id: string;
|
|
|
|
username: string;
|
|
|
|
token: string;
|
|
|
|
status: string;
|
|
|
|
lastMessageTs: Date;
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
_id: string; // _id belongs watermelonDB
|
|
|
|
id: string; // id from server
|
2022-02-21 19:41:49 +00:00
|
|
|
_updatedAt?: string; // from server
|
|
|
|
v?: IVisitor;
|
2022-01-11 13:51:48 +00:00
|
|
|
f: boolean;
|
2022-03-02 14:49:43 +00:00
|
|
|
t: string; // 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;
|
|
|
|
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[];
|
|
|
|
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;
|
|
|
|
jitsiTimeout?: number;
|
|
|
|
autoTranslate?: boolean;
|
2022-03-02 14:18:01 +00:00
|
|
|
autoTranslateLanguage?: string;
|
|
|
|
lastMessage?: ILastMessage; // 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;
|
|
|
|
encrypted?: boolean;
|
|
|
|
e2eKeyId?: string;
|
|
|
|
avatarETag?: string;
|
|
|
|
teamId?: string;
|
|
|
|
teamMain?: boolean;
|
2022-02-25 18:59:39 +00:00
|
|
|
separator?: boolean;
|
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>;
|
2022-01-11 13:51:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type TSubscriptionModel = ISubscription & Model;
|
2022-02-21 19:41:49 +00:00
|
|
|
|
|
|
|
export interface IServerSubscriptionItem {
|
|
|
|
_id: string;
|
|
|
|
rid: string;
|
|
|
|
u: {
|
|
|
|
_id: string;
|
|
|
|
username: string;
|
|
|
|
};
|
|
|
|
_updatedAt: string;
|
|
|
|
alert: boolean;
|
|
|
|
fname: string;
|
|
|
|
groupMentions: number;
|
|
|
|
name: string;
|
|
|
|
open: boolean;
|
|
|
|
t: string;
|
|
|
|
unread: number;
|
|
|
|
userMentions: number;
|
|
|
|
ls: string;
|
|
|
|
lr: string;
|
|
|
|
tunread: number[] | [];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IServerSubscription {
|
|
|
|
update: IServerSubscriptionItem[];
|
|
|
|
remove: IServerSubscriptionItem[];
|
|
|
|
success: boolean;
|
|
|
|
}
|