Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/definitions/IRocketChatRecord.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface IRocketChatRecord {
_id?: string;
_id: string;
_updatedAt?: Date;
}

Expand Down
137 changes: 91 additions & 46 deletions app/definitions/IRoom.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Model from '@nozbe/watermelondb/Model';
import { MarkdownAST } from '@rocket.chat/message-parser';

import { IAttachment } from './IAttachment';
import { IMessage } from './IMessage';
import { IRocketChatRecord } from './IRocketChatRecord';
import { IServedBy } from './IServedBy';
import { SubscriptionType } from './ISubscription';
import { IUser } from './IUser';
Expand All @@ -15,7 +14,6 @@ interface IRequestTranscript {
}

export interface IRoom {
_id?: string;
fname?: string;
id: string;
rid: string;
Expand Down Expand Up @@ -45,6 +43,20 @@ export interface IRoom {
muted?: string[];
teamId?: string;
ignored?: string;

_updatedAt?: Date;
archived?: boolean;
announcement?: string;
description?: string;
lastMessage?: IMessage;
topic?: string;
reactWhenReadOnly?: boolean;
joinCodeRequired?: boolean;
jitsiTimeout?: Date;
usernames?: string[];
uids: Array<string>;
lm?: Date;
sysMes?: string[];
}

export enum OmnichannelSourceType {
Expand All @@ -55,7 +67,7 @@ export enum OmnichannelSourceType {
API = 'api',
OTHER = 'other' // catch-all source type
}
export interface IOmnichannelRoom extends Omit<IRoom, 'default' | 'featured' | 'broadcast' | ''> {
export interface IOmnichannelRoom extends Omit<IServerRoom, 'default' | 'featured' | 'broadcast' | ''> {
t: SubscriptionType.OMNICHANNEL;
v: {
_id?: string;
Expand Down Expand Up @@ -107,51 +119,84 @@ export interface IOmnichannelRoom extends Omit<IRoom, 'default' | 'featured' | '

export type TRoomModel = IRoom & Model;

export interface IServerRoomItem {
_id: string;
name: string;
export type RoomType = 'c' | 'd' | 'p' | 'l';
export type RoomID = string;
export type ChannelName = string;

// https://github.com/RocketChat/Rocket.Chat/blob/43fa95aeaf5716d728bad943c6a07d1ee7172ee2/definition/IRoom.ts#L17
export interface IServerRoom extends IRocketChatRecord {
_id: RoomID;
t: RoomType;
name?: string;
fname: string;
t: SubscriptionType;
u: {
msgs: number;
default?: true;
broadcast?: true;
featured?: true;
encrypted?: boolean;
topic?: any;

u: Pick<IUser, '_id' | 'username' | 'name'>;
uids: Array<string>;

lastMessage?: IMessage;
lm?: Date;
usersCount: number;
jitsiTimeout?: Date;
webRtcCallStartTime?: Date;
servedBy?: {
_id: string;
username: string;
};
customFields: {};
ts: string;
ro: boolean;
_updatedAt: string;
lm: string;
lastMessage: {
alias: string;
msg: string;
attachments: IAttachment[];
parseUrls: boolean;
bot: {
i: string;
};
groupable: boolean;
avatar: string;
ts: string;
u: IUser;
rid: string;
_id: string;
_updatedAt: string;
mentions: [];
channels: [];
md: MarkdownAST;

streamingOptions?: {
id?: string;
type: string;
};
topic: string;
joinCodeRequired: boolean;
description: string;
jitsiTimeout: string;
usersCount: number;
e2eKeyId: string;
avatarETag: string;
encrypted: boolean;
}

export interface IServerRoom {
update: IServerRoomItem[];
remove: IServerRoomItem[];
success: boolean;
prid?: string;
avatarETag?: string;
tokenpass?: {
require: string;
tokens: {
token: string;
balance: number;
}[];
};

teamMain?: boolean;
teamId?: string;
teamDefault?: boolean;
open?: boolean;

autoTranslateLanguage: string;
autoTranslate?: boolean;
unread?: number;
alert?: boolean;
hideUnreadStatus?: boolean;

sysMes?: string[];
muted?: string[];
unmuted?: string[];

usernames?: string[];
ts?: Date;

cl?: boolean;
ro?: boolean;
favorite?: boolean;
archived?: boolean;
announcement?: string;
description?: string;

reactWhenReadOnly?: boolean;
joinCodeRequired?: boolean;
e2eKeyId?: string;
v?: {
_id?: string;
token?: string;
status: 'online' | 'busy' | 'away' | 'offline';
};
departmentId?: string;
livechatData?: any;
tags?: string[];
}
4 changes: 2 additions & 2 deletions app/definitions/IServedBy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface IServedBy {
_id: string;
username: string;
ts: Date;
username?: string;
ts?: Date;
}
91 changes: 61 additions & 30 deletions app/definitions/ISubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import Model from '@nozbe/watermelondb/Model';
import Relation from '@nozbe/watermelondb/Relation';

import { ILastMessage, TMessageModel } from './IMessage';
import { IRocketChatRecord } from './IRocketChatRecord';
import { RoomID, RoomType } from './IRoom';
import { IServedBy } from './IServedBy';
import { TThreadModel } from './IThread';
import { TThreadMessageModel } from './IThreadMessage';
import { TUploadModel } from './IUpload';
import { IUser } from './IUser';

export enum SubscriptionType {
GROUP = 'p',
Expand All @@ -17,11 +20,11 @@ export enum SubscriptionType {
}

export interface IVisitor {
_id: string;
username: string;
token: string;
status: string;
lastMessageTs: Date;
_id?: string;
username?: string;
token?: string;
status?: string;
lastMessageTs?: Date;
}

export enum ERoomTypes {
Expand All @@ -31,9 +34,9 @@ export enum ERoomTypes {
}

export interface ISubscription {
_id: string; // _id belongs watermelonDB
id: string; // id from server
_updatedAt?: string; // from server
_id: string;
id: string;
_updatedAt?: string;
v?: IVisitor;
f: boolean;
t: SubscriptionType;
Expand Down Expand Up @@ -71,7 +74,7 @@ export interface ISubscription {
prid?: string;
draftMessage?: string | null;
lastThreadSync?: Date;
jitsiTimeout?: number;
jitsiTimeout?: Date;
autoTranslate?: boolean;
autoTranslateLanguage: string;
lastMessage?: ILastMessage;
Expand Down Expand Up @@ -100,29 +103,57 @@ export interface ISubscription {

export type TSubscriptionModel = ISubscription & Model;

export interface IServerSubscriptionItem {
_id: string;
rid: string;
u: {
_id: string;
username: string;
};
_updatedAt: string;
alert: boolean;
fname: string;
groupMentions: number;
name: string;
// 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;
open: boolean;
t: string;
ts: Date;

name: string;

alert?: boolean;
unread: number;
t: RoomType;
ls: Date;
f?: true;
lr: Date;
hideUnreadStatus?: true;
teamMain?: boolean;
teamId?: string;

userMentions: number;
ls: string;
lr: string;
tunread: number[] | [];
}
groupMentions: number;

tunread?: Array<string>;
tunreadGroup?: Array<string>;
tunreadUser?: Array<string>;

prid?: RoomID;

roles?: string[];

onHold?: boolean;
encrypted?: boolean;
E2EKey?: string;
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;

export interface IServerSubscription {
update: IServerSubscriptionItem[];
remove: IServerSubscriptionItem[];
success: boolean;
department?: unknown;
}
6 changes: 3 additions & 3 deletions app/definitions/rest/v1/channels.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { IMessage } from '../../IMessage';
import type { IRoom } from '../../IRoom';
import type { IServerRoom } from '../../IRoom';
import type { IUser } from '../../IUser';

export type ChannelsEndpoints = {
'channels.files': {
GET: (params: { roomId: IRoom['_id']; offset: number; count: number; sort: string; query: string }) => {
GET: (params: { roomId: IServerRoom['_id']; offset: number; count: number; sort: string; query: string }) => {
files: IMessage[];
total: number;
};
};
'channels.members': {
GET: (params: { roomId: IRoom['_id']; offset?: number; count?: number; filter?: string; status?: string[] }) => {
GET: (params: { roomId: IServerRoom['_id']; offset?: number; count?: number; filter?: string; status?: string[] }) => {
count: number;
offset: number;
members: IUser[];
Expand Down
6 changes: 3 additions & 3 deletions app/definitions/rest/v1/chat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IMessage } from '../../IMessage';
import type { IRoom } from '../../IRoom';
import type { IServerRoom } from '../../IRoom';
import { PaginatedResult } from '../helpers/PaginatedResult';

export type ChatEndpoints = {
Expand All @@ -15,14 +15,14 @@ export type ChatEndpoints = {
POST: (params: { mid: IMessage['_id'] }) => void;
};
'chat.getDiscussions': {
GET: (params: { roomId: IRoom['_id']; text?: string; offset: number; count: number }) => {
GET: (params: { roomId: IServerRoom['_id']; text?: string; offset: number; count: number }) => {
messages: IMessage[];
total: number;
};
};
'chat.getThreadsList': {
GET: (params: {
rid: IRoom['_id'];
rid: IServerRoom['_id'];
type: 'unread' | 'following' | 'all';
text?: string;
offset: number;
Expand Down
4 changes: 2 additions & 2 deletions app/definitions/rest/v1/dm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IRoom } from '../../IRoom';
import type { IServerRoom } from '../../IRoom';
import type { IUser } from '../../IUser';

export type DmEndpoints = {
Expand All @@ -15,7 +15,7 @@ export type DmEndpoints = {
excludeSelf?: boolean;
}
) => {
room: IRoom & { rid: IRoom['_id'] };
room: IServerRoom & { rid: IServerRoom['_id'] };
};
};
};
Loading