Chore: Create IServerRoom and IServerSubscription (#3782)
This commit is contained in:
parent
679a628f75
commit
09f73aee3d
|
@ -1,5 +1,5 @@
|
||||||
export interface IRocketChatRecord {
|
export interface IRocketChatRecord {
|
||||||
_id?: string;
|
_id: string;
|
||||||
_updatedAt?: Date;
|
_updatedAt?: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import Model from '@nozbe/watermelondb/Model';
|
import Model from '@nozbe/watermelondb/Model';
|
||||||
import { MarkdownAST } from '@rocket.chat/message-parser';
|
|
||||||
|
|
||||||
import { IAttachment } from './IAttachment';
|
|
||||||
import { IMessage } from './IMessage';
|
import { IMessage } from './IMessage';
|
||||||
|
import { IRocketChatRecord } from './IRocketChatRecord';
|
||||||
import { IServedBy } from './IServedBy';
|
import { IServedBy } from './IServedBy';
|
||||||
import { IVisitor, SubscriptionType } from './ISubscription';
|
import { IVisitor, SubscriptionType } from './ISubscription';
|
||||||
import { IUser } from './IUser';
|
import { IUser } from './IUser';
|
||||||
|
@ -15,8 +14,8 @@ interface IRequestTranscript {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IRoom {
|
export interface IRoom {
|
||||||
_id: string;
|
|
||||||
fname?: string;
|
fname?: string;
|
||||||
|
_id: string;
|
||||||
id: string;
|
id: string;
|
||||||
rid: string;
|
rid: string;
|
||||||
prid: string;
|
prid: string;
|
||||||
|
@ -37,11 +36,25 @@ export interface IRoom {
|
||||||
e2eKeyId?: string;
|
e2eKeyId?: string;
|
||||||
avatarETag?: string;
|
avatarETag?: string;
|
||||||
latest?: string;
|
latest?: string;
|
||||||
default?: true;
|
default?: boolean;
|
||||||
featured?: true;
|
featured?: boolean;
|
||||||
muted?: string[];
|
muted?: string[];
|
||||||
teamId?: string;
|
teamId?: string;
|
||||||
ignored?: 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 {
|
export enum OmnichannelSourceType {
|
||||||
|
@ -108,51 +121,84 @@ export interface IOmnichannelRoom extends Partial<Omit<IRoom, 'default' | 'featu
|
||||||
|
|
||||||
export type TRoomModel = IRoom & Model;
|
export type TRoomModel = IRoom & Model;
|
||||||
|
|
||||||
export interface IServerRoomItem {
|
export type RoomType = 'c' | 'd' | 'p' | 'l';
|
||||||
_id: string;
|
export type RoomID = string;
|
||||||
name: string;
|
export type ChannelName = string;
|
||||||
fname: string;
|
|
||||||
t: SubscriptionType;
|
|
||||||
u: {
|
|
||||||
_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;
|
|
||||||
};
|
|
||||||
topic: string;
|
|
||||||
joinCodeRequired: boolean;
|
|
||||||
description: string;
|
|
||||||
jitsiTimeout: string;
|
|
||||||
usersCount: number;
|
|
||||||
e2eKeyId: string;
|
|
||||||
avatarETag: string;
|
|
||||||
encrypted: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IServerRoom {
|
// https://github.com/RocketChat/Rocket.Chat/blob/43fa95aeaf5716d728bad943c6a07d1ee7172ee2/definition/IRoom.ts#L17
|
||||||
update: IServerRoomItem[];
|
export interface IServerRoom extends IRocketChatRecord {
|
||||||
remove: IServerRoomItem[];
|
_id: RoomID;
|
||||||
success: boolean;
|
t: RoomType;
|
||||||
|
name?: string;
|
||||||
|
fname: string;
|
||||||
|
msgs: number;
|
||||||
|
default?: boolean;
|
||||||
|
broadcast?: boolean;
|
||||||
|
featured?: boolean;
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
streamingOptions?: {
|
||||||
|
id?: string;
|
||||||
|
type: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
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[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export interface IServedBy {
|
export interface IServedBy {
|
||||||
_id: string;
|
_id: string;
|
||||||
username: string;
|
username?: string;
|
||||||
ts: Date;
|
ts?: Date;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { IServerRoomItem } from './IRoom';
|
import { IServerRoom } from './IRoom';
|
||||||
import { IUser } from './IUser';
|
import { IUser } from './IUser';
|
||||||
|
|
||||||
export type TSpotlightUser = Pick<IUser, '_id' | 'status' | 'name' | 'username'> & { outside: boolean };
|
export type TSpotlightUser = Pick<IUser, '_id' | 'status' | 'name' | 'username'> & { outside: boolean };
|
||||||
|
|
||||||
export type ISpotlightRoom = Pick<IServerRoomItem, '_id' | 'name' | 't'> & Partial<Pick<IServerRoomItem, 'lastMessage'>>;
|
export type ISpotlightRoom = Pick<IServerRoom, '_id' | 'name' | 't'> & Partial<Pick<IServerRoom, 'lastMessage'>>;
|
||||||
|
|
||||||
export interface ISpotlight {
|
export interface ISpotlight {
|
||||||
users: TSpotlightUser[];
|
users: TSpotlightUser[];
|
||||||
|
|
|
@ -2,10 +2,13 @@ import Model from '@nozbe/watermelondb/Model';
|
||||||
import Relation from '@nozbe/watermelondb/Relation';
|
import Relation from '@nozbe/watermelondb/Relation';
|
||||||
|
|
||||||
import { ILastMessage, TMessageModel } from './IMessage';
|
import { ILastMessage, TMessageModel } from './IMessage';
|
||||||
|
import { IRocketChatRecord } from './IRocketChatRecord';
|
||||||
|
import { RoomID, RoomType } from './IRoom';
|
||||||
import { IServedBy } from './IServedBy';
|
import { IServedBy } from './IServedBy';
|
||||||
import { TThreadModel } from './IThread';
|
import { TThreadModel } from './IThread';
|
||||||
import { TThreadMessageModel } from './IThreadMessage';
|
import { TThreadMessageModel } from './IThreadMessage';
|
||||||
import { TUploadModel } from './IUpload';
|
import { TUploadModel } from './IUpload';
|
||||||
|
import { IUser } from './IUser';
|
||||||
|
|
||||||
export enum SubscriptionType {
|
export enum SubscriptionType {
|
||||||
GROUP = 'p',
|
GROUP = 'p',
|
||||||
|
@ -33,9 +36,9 @@ export enum ERoomTypes {
|
||||||
type RelationModified<T extends Model> = { fetch(): Promise<T[]> } & Relation<T>;
|
type RelationModified<T extends Model> = { fetch(): Promise<T[]> } & Relation<T>;
|
||||||
|
|
||||||
export interface ISubscription {
|
export interface ISubscription {
|
||||||
_id: string; // _id belongs watermelonDB
|
_id: string;
|
||||||
id: string; // id from server
|
id: string;
|
||||||
_updatedAt?: string; // from server
|
_updatedAt?: string;
|
||||||
v?: IVisitor;
|
v?: IVisitor;
|
||||||
f: boolean;
|
f: boolean;
|
||||||
t: SubscriptionType; // TODO: we need to review this type later
|
t: SubscriptionType; // TODO: we need to review this type later
|
||||||
|
@ -73,7 +76,7 @@ export interface ISubscription {
|
||||||
prid?: string;
|
prid?: string;
|
||||||
draftMessage?: string | null;
|
draftMessage?: string | null;
|
||||||
lastThreadSync?: Date;
|
lastThreadSync?: Date;
|
||||||
jitsiTimeout?: number;
|
jitsiTimeout?: Date;
|
||||||
autoTranslate?: boolean;
|
autoTranslate?: boolean;
|
||||||
autoTranslateLanguage?: string;
|
autoTranslateLanguage?: string;
|
||||||
lastMessage?: ILastMessage | null; // TODO: we need to use IMessage here
|
lastMessage?: ILastMessage | null; // TODO: we need to use IMessage here
|
||||||
|
@ -104,29 +107,57 @@ export interface ISubscription {
|
||||||
|
|
||||||
export type TSubscriptionModel = ISubscription & Model;
|
export type TSubscriptionModel = ISubscription & Model;
|
||||||
|
|
||||||
export interface IServerSubscriptionItem {
|
// https://github.com/RocketChat/Rocket.Chat/blob/a88a96fcadd925b678ff27ada37075e029f78b5e/definition/ISubscription.ts#L8
|
||||||
_id: string;
|
export interface IServerSubscription extends IRocketChatRecord {
|
||||||
rid: string;
|
u: Pick<IUser, '_id' | 'username' | 'name'>;
|
||||||
u: {
|
v?: Pick<IUser, '_id' | 'username' | 'name'>;
|
||||||
_id: string;
|
rid: RoomID;
|
||||||
username: string;
|
|
||||||
};
|
|
||||||
_updatedAt: string;
|
|
||||||
alert: boolean;
|
|
||||||
fname: string;
|
|
||||||
groupMentions: number;
|
|
||||||
name: string;
|
|
||||||
open: boolean;
|
open: boolean;
|
||||||
t: string;
|
ts: Date;
|
||||||
unread: number;
|
|
||||||
userMentions: number;
|
|
||||||
ls: string;
|
|
||||||
lr: string;
|
|
||||||
tunread: number[] | [];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IServerSubscription {
|
name: string;
|
||||||
update: IServerSubscriptionItem[];
|
|
||||||
remove: IServerSubscriptionItem[];
|
alert?: boolean;
|
||||||
success: boolean;
|
unread: number;
|
||||||
|
t: RoomType;
|
||||||
|
ls: Date;
|
||||||
|
f?: true;
|
||||||
|
lr: Date;
|
||||||
|
hideUnreadStatus?: true;
|
||||||
|
teamMain?: boolean;
|
||||||
|
teamId?: string;
|
||||||
|
|
||||||
|
userMentions: 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;
|
||||||
|
|
||||||
|
department?: unknown;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { IRocketChatRecord } from './IRocketChatRecord';
|
import { IRocketChatRecord } from './IRocketChatRecord';
|
||||||
import { IUser } from './IUser';
|
import { IUser } from './IUser';
|
||||||
import { IServerRoomItem } from './IRoom';
|
import { IServerRoom } from './IRoom';
|
||||||
|
|
||||||
export enum TEAM_TYPE {
|
export enum TEAM_TYPE {
|
||||||
PUBLIC = 0,
|
PUBLIC = 0,
|
||||||
|
@ -50,13 +50,9 @@ export interface ITeamStats {
|
||||||
|
|
||||||
export interface IServerTeamUpdateRoom
|
export interface IServerTeamUpdateRoom
|
||||||
extends Omit<
|
extends Omit<
|
||||||
IServerRoomItem,
|
IServerRoom,
|
||||||
'topic' | 'joinCodeRequired' | 'description' | 'jitsiTimeout' | 'usersCount' | 'e2eKeyId' | 'avatarETag'
|
'topic' | 'joinCodeRequired' | 'description' | 'jitsiTimeout' | 'usersCount' | 'e2eKeyId' | 'avatarETag'
|
||||||
> {
|
> {
|
||||||
broadcast: boolean;
|
|
||||||
msgs: number;
|
|
||||||
default: boolean;
|
|
||||||
sysMes: boolean;
|
|
||||||
teamId: string;
|
teamId: string;
|
||||||
teamDefault: boolean;
|
teamDefault: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { ITeam } from '../../ITeam';
|
import { ITeam } from '../../ITeam';
|
||||||
import type { IMessage, IMessageFromServer } from '../../IMessage';
|
import type { IMessage, IMessageFromServer } from '../../IMessage';
|
||||||
import type { IRoom, IServerRoomItem } from '../../IRoom';
|
import type { IServerRoom } from '../../IRoom';
|
||||||
import type { IUser } from '../../IUser';
|
import type { IUser } from '../../IUser';
|
||||||
|
|
||||||
export type ChannelsEndpoints = {
|
export type ChannelsEndpoints = {
|
||||||
'channels.files': {
|
'channels.files': {
|
||||||
GET: (params: {
|
GET: (params: {
|
||||||
roomId: IRoom['_id'];
|
roomId: IServerRoom['_id'];
|
||||||
offset: number;
|
offset: number;
|
||||||
count: number;
|
count: number;
|
||||||
sort: string | { uploadedAt: number };
|
sort: string | { uploadedAt: number };
|
||||||
|
@ -17,7 +17,7 @@ export type ChannelsEndpoints = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'channels.members': {
|
'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;
|
count: number;
|
||||||
offset: number;
|
offset: number;
|
||||||
members: IUser[];
|
members: IUser[];
|
||||||
|
@ -46,14 +46,14 @@ export type ChannelsEndpoints = {
|
||||||
teamId?: string;
|
teamId?: string;
|
||||||
};
|
};
|
||||||
}) => {
|
}) => {
|
||||||
group: Partial<IServerRoomItem>;
|
group: Partial<IServerRoom>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'channels.convertToTeam': {
|
'channels.convertToTeam': {
|
||||||
POST: (params: { channelId: string; channelName: string }) => { team: ITeam };
|
POST: (params: { channelId: string; channelName: string }) => { team: ITeam };
|
||||||
};
|
};
|
||||||
'channels.info': {
|
'channels.info': {
|
||||||
GET: (params: { roomId: string }) => { channel: IServerRoomItem };
|
GET: (params: { roomId: string }) => { channel: IServerRoom };
|
||||||
};
|
};
|
||||||
'channels.counters': {
|
'channels.counters': {
|
||||||
GET: (params: { roomId: string }) => {
|
GET: (params: { roomId: string }) => {
|
||||||
|
@ -67,7 +67,7 @@ export type ChannelsEndpoints = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'channels.join': {
|
'channels.join': {
|
||||||
POST: (params: { roomId: string; joinCode: string | null }) => { channel: IServerRoomItem };
|
POST: (params: { roomId: string; joinCode: string | null }) => { channel: IServerRoom };
|
||||||
};
|
};
|
||||||
'channels.close': {
|
'channels.close': {
|
||||||
POST: (params: { roomId: string }) => {};
|
POST: (params: { roomId: string }) => {};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { IMessage } from '../../IMessage';
|
import type { IMessage } from '../../IMessage';
|
||||||
import type { IRoom } from '../../IRoom';
|
import type { IServerRoom } from '../../IRoom';
|
||||||
import { PaginatedResult } from '../helpers/PaginatedResult';
|
import { PaginatedResult } from '../helpers/PaginatedResult';
|
||||||
|
|
||||||
export type ChatEndpoints = {
|
export type ChatEndpoints = {
|
||||||
|
@ -30,14 +30,14 @@ export type ChatEndpoints = {
|
||||||
POST: (params: { messageId: IMessage['_id']; description: string }) => void;
|
POST: (params: { messageId: IMessage['_id']; description: string }) => void;
|
||||||
};
|
};
|
||||||
'chat.getDiscussions': {
|
'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[];
|
messages: IMessage[];
|
||||||
total: number;
|
total: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'chat.getThreadsList': {
|
'chat.getThreadsList': {
|
||||||
GET: (params: {
|
GET: (params: {
|
||||||
rid: IRoom['_id'];
|
rid: IServerRoom['_id'];
|
||||||
type: 'unread' | 'following' | 'all';
|
type: 'unread' | 'following' | 'all';
|
||||||
text?: string;
|
text?: string;
|
||||||
offset: number;
|
offset: number;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { IRoom } from '../../IRoom';
|
import type { IServerRoom } from '../../IRoom';
|
||||||
import type { IUser } from '../../IUser';
|
import type { IUser } from '../../IUser';
|
||||||
|
|
||||||
export type DmEndpoints = {
|
export type DmEndpoints = {
|
||||||
|
@ -15,7 +15,7 @@ export type DmEndpoints = {
|
||||||
excludeSelf?: boolean;
|
excludeSelf?: boolean;
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
room: IRoom & { rid: IRoom['_id'] };
|
room: IServerRoom & { rid: IServerRoom['_id'] };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import { ITeam } from '../../ITeam';
|
import { ITeam } from '../../ITeam';
|
||||||
import type { IMessage, IMessageFromServer } from '../../IMessage';
|
import type { IMessage, IMessageFromServer } from '../../IMessage';
|
||||||
import type { IRoom, IServerRoomItem } from '../../IRoom';
|
import type { IServerRoom } from '../../IRoom';
|
||||||
import type { IUser } from '../../IUser';
|
import type { IUser } from '../../IUser';
|
||||||
|
|
||||||
export type GroupsEndpoints = {
|
export type GroupsEndpoints = {
|
||||||
'groups.files': {
|
'groups.files': {
|
||||||
GET: (params: { roomId: IRoom['_id']; count: number; sort: string | { uploadedAt: number }; query: string }) => {
|
GET: (params: { roomId: IServerRoom['_id']; count: number; sort: string | { uploadedAt: number }; query: string }) => {
|
||||||
files: IMessage[];
|
files: IMessage[];
|
||||||
total: number;
|
total: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'groups.members': {
|
'groups.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;
|
count: number;
|
||||||
offset: number;
|
offset: number;
|
||||||
members: IUser[];
|
members: IUser[];
|
||||||
|
@ -40,7 +40,7 @@ export type GroupsEndpoints = {
|
||||||
teamId?: string;
|
teamId?: string;
|
||||||
};
|
};
|
||||||
}) => {
|
}) => {
|
||||||
group: Partial<IServerRoomItem>;
|
group: Partial<IServerRoom>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'groups.convertToTeam': {
|
'groups.convertToTeam': {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { IMessage, IMessageFromServer } from '../../IMessage';
|
import type { IMessage, IMessageFromServer } from '../../IMessage';
|
||||||
import type { IRoom } from '../../IRoom';
|
import type { IServerRoom, RoomID, RoomType } from '../../IRoom';
|
||||||
import type { IUser } from '../../IUser';
|
import type { IUser } from '../../IUser';
|
||||||
|
|
||||||
export type ImEndpoints = {
|
export type ImEndpoints = {
|
||||||
|
@ -16,17 +16,22 @@ export type ImEndpoints = {
|
||||||
excludeSelf?: boolean;
|
excludeSelf?: boolean;
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
room: IRoom;
|
room: {
|
||||||
|
t: RoomType;
|
||||||
|
rid: RoomID;
|
||||||
|
_id: RoomID;
|
||||||
|
usernames: IServerRoom['usernames'];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'im.files': {
|
'im.files': {
|
||||||
GET: (params: { roomId: IRoom['_id']; count: number; sort: string | { uploadedAt: number }; query: string }) => {
|
GET: (params: { roomId: IServerRoom['_id']; count: number; sort: string | { uploadedAt: number }; query: string }) => {
|
||||||
files: IMessage[];
|
files: IMessage[];
|
||||||
total: number;
|
total: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'im.members': {
|
'im.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;
|
count: number;
|
||||||
offset: number;
|
offset: number;
|
||||||
members: IUser[];
|
members: IUser[];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { IInvite } from '../../IInvite';
|
import type { IInvite } from '../../IInvite';
|
||||||
import type { IRoom } from '../../IRoom';
|
import type { IServerRoom } from '../../IRoom';
|
||||||
|
|
||||||
export type InvitesEndpoints = {
|
export type InvitesEndpoints = {
|
||||||
listInvites: {
|
listInvites: {
|
||||||
|
@ -11,11 +11,11 @@ export type InvitesEndpoints = {
|
||||||
'/v1/useInviteToken': {
|
'/v1/useInviteToken': {
|
||||||
POST: (params: { token: string }) => {
|
POST: (params: { token: string }) => {
|
||||||
room: {
|
room: {
|
||||||
rid: IRoom['_id'];
|
rid: IServerRoom['_id'];
|
||||||
prid: IRoom['prid'];
|
prid: IServerRoom['prid'];
|
||||||
fname: IRoom['fname'];
|
fname: IServerRoom['fname'];
|
||||||
name: IRoom['name'];
|
name: IServerRoom['name'];
|
||||||
t: IRoom['t'];
|
t: IServerRoom['t'];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ILivechatMonitor } from '../../ILivechatMonitor';
|
||||||
import { ILivechatTag } from '../../ILivechatTag';
|
import { ILivechatTag } from '../../ILivechatTag';
|
||||||
import { ILivechatVisitor, ILivechatVisitorDTO } from '../../ILivechatVisitor';
|
import { ILivechatVisitor, ILivechatVisitorDTO } from '../../ILivechatVisitor';
|
||||||
import { IMessage } from '../../IMessage';
|
import { IMessage } from '../../IMessage';
|
||||||
import { IOmnichannelRoom, IRoom } from '../../IRoom';
|
import { IOmnichannelRoom, IServerRoom } from '../../IRoom';
|
||||||
import { ISetting } from '../../ISetting';
|
import { ISetting } from '../../ISetting';
|
||||||
import { PaginatedRequest } from '../helpers/PaginatedRequest';
|
import { PaginatedRequest } from '../helpers/PaginatedRequest';
|
||||||
import { PaginatedResult } from '../helpers/PaginatedResult';
|
import { PaginatedResult } from '../helpers/PaginatedResult';
|
||||||
|
@ -25,7 +25,7 @@ export type OmnichannelEndpoints = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'livechat/room.onHold': {
|
'livechat/room.onHold': {
|
||||||
POST: (params: { roomId: IRoom['_id'] }) => void;
|
POST: (params: { roomId: IServerRoom['_id'] }) => void;
|
||||||
};
|
};
|
||||||
'livechat/monitors.list': {
|
'livechat/monitors.list': {
|
||||||
GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{
|
GET: (params: PaginatedRequest<{ text: string }>) => PaginatedResult<{
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import type { IMessage } from '../../IMessage';
|
import type { IMessage } from '../../IMessage';
|
||||||
import type { IRoom } from '../../IRoom';
|
import type { IServerRoom } from '../../IRoom';
|
||||||
import type { IUser } from '../../IUser';
|
import type { IUser } from '../../IUser';
|
||||||
|
|
||||||
export type RoomsEndpoints = {
|
export type RoomsEndpoints = {
|
||||||
'rooms.autocomplete.channelAndPrivate': {
|
'rooms.autocomplete.channelAndPrivate': {
|
||||||
GET: (params: { selector: string }) => {
|
GET: (params: { selector: string }) => {
|
||||||
items: IRoom[];
|
items: IServerRoom[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'rooms.autocomplete.channelAndPrivate.withPagination': {
|
'rooms.autocomplete.channelAndPrivate.withPagination': {
|
||||||
GET: (params: { selector: string; offset?: number; count?: number; sort?: string }) => {
|
GET: (params: { selector: string; offset?: number; count?: number; sort?: string }) => {
|
||||||
items: IRoom[];
|
items: IServerRoom[];
|
||||||
count: number;
|
count: number;
|
||||||
offset: number;
|
offset: number;
|
||||||
total: number;
|
total: number;
|
||||||
|
@ -18,24 +18,24 @@ export type RoomsEndpoints = {
|
||||||
};
|
};
|
||||||
'rooms.autocomplete.availableForTeams': {
|
'rooms.autocomplete.availableForTeams': {
|
||||||
GET: (params: { name: string }) => {
|
GET: (params: { name: string }) => {
|
||||||
items: IRoom[];
|
items: IServerRoom[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'rooms.info': {
|
'rooms.info': {
|
||||||
GET: (params: { roomId: string } | { roomName: string }) => {
|
GET: (params: { roomId: string } | { roomName: string }) => {
|
||||||
room: IRoom;
|
room: IServerRoom;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'rooms.createDiscussion': {
|
'rooms.createDiscussion': {
|
||||||
POST: (params: {
|
POST: (params: {
|
||||||
prid: IRoom['_id'];
|
prid: IServerRoom['_id'];
|
||||||
pmid?: IMessage['_id'];
|
pmid?: IMessage['_id'];
|
||||||
t_name: IRoom['fname'];
|
t_name: IServerRoom['fname'];
|
||||||
users?: IUser['username'][];
|
users?: IUser['username'][];
|
||||||
encrypted?: boolean;
|
encrypted?: boolean;
|
||||||
reply?: string;
|
reply?: string;
|
||||||
}) => {
|
}) => {
|
||||||
discussion: IRoom;
|
discussion: IServerRoom;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'rooms.favorite': {
|
'rooms.favorite': {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { IRoom, IServerRoomItem } from '../../IRoom';
|
import { IServerRoom } from '../../IRoom';
|
||||||
import { IServerTeamUpdateRoom, ITeam, TEAM_TYPE } from '../../ITeam';
|
import { IServerTeamUpdateRoom, ITeam, TEAM_TYPE } from '../../ITeam';
|
||||||
|
|
||||||
export type TeamsEndpoints = {
|
export type TeamsEndpoints = {
|
||||||
'teams.removeRoom': {
|
'teams.removeRoom': {
|
||||||
POST: (params: { roomId: string; teamId: string }) => { room: IServerRoomItem };
|
POST: (params: { roomId: string; teamId: string }) => { room: IServerRoom };
|
||||||
};
|
};
|
||||||
'teams.listRoomsOfUser': {
|
'teams.listRoomsOfUser': {
|
||||||
GET: (params: { teamId: string; userId: string }) => {
|
GET: (params: { teamId: string; userId: string }) => {
|
||||||
rooms: IServerRoomItem[];
|
rooms: IServerRoom[];
|
||||||
total: number;
|
total: number;
|
||||||
count: number;
|
count: number;
|
||||||
offset: number;
|
offset: number;
|
||||||
|
@ -23,7 +23,7 @@ export type TeamsEndpoints = {
|
||||||
POST: (params: { teamId: string; userId: string; rooms?: string[] }) => {};
|
POST: (params: { teamId: string; userId: string; rooms?: string[] }) => {};
|
||||||
};
|
};
|
||||||
'teams.addRooms': {
|
'teams.addRooms': {
|
||||||
POST: (params: { teamId: string; rooms: string[] }) => { rooms: IRoom[] };
|
POST: (params: { teamId: string; rooms: string[] }) => { rooms: IServerRoom[] };
|
||||||
};
|
};
|
||||||
'teams.create': {
|
'teams.create': {
|
||||||
POST: (params: {
|
POST: (params: {
|
||||||
|
|
|
@ -20,8 +20,10 @@ async function open({ type, rid, name }: { type: ERoomTypes; rid: string; name:
|
||||||
const result = await RocketChat.createDirectMessage(name);
|
const result = await RocketChat.createDirectMessage(name);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const { room } = result;
|
const { room } = result;
|
||||||
room.rid = room._id as string;
|
return {
|
||||||
return room;
|
...room,
|
||||||
|
rid: room._id
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
import { IRoom, SubscriptionType } from '../../definitions';
|
import { IServerSubscription, RoomType } from '../../definitions';
|
||||||
import { getSubscriptionByRoomId } from '../database/services/Subscription';
|
import { getSubscriptionByRoomId } from '../database/services/Subscription';
|
||||||
import RocketChat from '../rocketchat';
|
import RocketChat from '../rocketchat';
|
||||||
|
|
||||||
const getRoomInfo = async (rid: string): Promise<Pick<IRoom, 'rid' | 'name' | 'fname' | 't'> | null> => {
|
export interface IRoomInfoResult {
|
||||||
|
rid: IServerSubscription['rid'];
|
||||||
|
name: IServerSubscription['name'];
|
||||||
|
fname: IServerSubscription['fname'];
|
||||||
|
t: IServerSubscription['t'];
|
||||||
|
}
|
||||||
|
|
||||||
|
const getRoomInfo = async (rid: string): Promise<IRoomInfoResult | null> => {
|
||||||
let result;
|
let result;
|
||||||
result = await getSubscriptionByRoomId(rid);
|
result = await getSubscriptionByRoomId(rid);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@ -10,7 +17,7 @@ const getRoomInfo = async (rid: string): Promise<Pick<IRoom, 'rid' | 'name' | 'f
|
||||||
rid,
|
rid,
|
||||||
name: result.name,
|
name: result.name,
|
||||||
fname: result.fname,
|
fname: result.fname,
|
||||||
t: result.t as SubscriptionType
|
t: result.t as RoomType
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +25,7 @@ const getRoomInfo = async (rid: string): Promise<Pick<IRoom, 'rid' | 'name' | 'f
|
||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
return {
|
return {
|
||||||
rid,
|
rid,
|
||||||
name: result.room.name,
|
name: result.room.name as string,
|
||||||
fname: result.room.fname,
|
fname: result.room.fname,
|
||||||
t: result.room.t
|
t: result.room.t
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { Q } from '@nozbe/watermelondb';
|
import { Q } from '@nozbe/watermelondb';
|
||||||
|
|
||||||
import { IServerSubscriptionItem, IServerRoomItem } from '../../../definitions';
|
import { IServerSubscription, IServerRoom } from '../../../definitions';
|
||||||
import database from '../../database';
|
import database from '../../database';
|
||||||
|
|
||||||
export default async (subscriptions: IServerSubscriptionItem[], rooms: IServerRoomItem[]) => {
|
export default async (subscriptions: IServerSubscription[], rooms: IServerRoom[]) => {
|
||||||
let sub = subscriptions;
|
let sub = subscriptions;
|
||||||
let room = rooms;
|
let room = rooms;
|
||||||
try {
|
try {
|
||||||
|
@ -59,7 +59,7 @@ export default async (subscriptions: IServerSubscriptionItem[], rooms: IServerRo
|
||||||
avatarETag: s.avatarETag
|
avatarETag: s.avatarETag
|
||||||
}));
|
}));
|
||||||
// Assign
|
// Assign
|
||||||
sub = subscriptions.concat(mappedExistingSubs as unknown as IServerSubscriptionItem);
|
sub = subscriptions.concat(mappedExistingSubs as unknown as IServerSubscription);
|
||||||
|
|
||||||
const subsIds = subscriptions.filter(s => !rooms.find(r => s.rid === r._id)).map(s => s._id);
|
const subsIds = subscriptions.filter(s => !rooms.find(r => s.rid === r._id)).map(s => s._id);
|
||||||
const existingRooms = await subCollection.query(Q.where('id', Q.oneOf(subsIds))).fetch();
|
const existingRooms = await subCollection.query(Q.where('id', Q.oneOf(subsIds))).fetch();
|
||||||
|
@ -89,7 +89,7 @@ export default async (subscriptions: IServerSubscriptionItem[], rooms: IServerRo
|
||||||
avatarETag: r.avatarETag
|
avatarETag: r.avatarETag
|
||||||
}));
|
}));
|
||||||
// Assign
|
// Assign
|
||||||
room = rooms.concat(mappedExistingRooms as unknown as IServerRoomItem);
|
room = rooms.concat(mappedExistingRooms as unknown as IServerRoom);
|
||||||
} catch {
|
} catch {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,104 +5,105 @@ import { store as reduxStore } from '../../auxStore';
|
||||||
import { compareServerVersion } from '../../utils';
|
import { compareServerVersion } from '../../utils';
|
||||||
import findSubscriptionsRooms from './findSubscriptionsRooms';
|
import findSubscriptionsRooms from './findSubscriptionsRooms';
|
||||||
import normalizeMessage from './normalizeMessage';
|
import normalizeMessage from './normalizeMessage';
|
||||||
import {
|
import { ISubscription, IServerSubscription, IServerRoom, IRoom } from '../../../definitions';
|
||||||
ISubscription,
|
|
||||||
IServerRoom,
|
|
||||||
IServerSubscription,
|
|
||||||
IServerSubscriptionItem,
|
|
||||||
IServerRoomItem,
|
|
||||||
IRoom
|
|
||||||
} from '../../../definitions';
|
|
||||||
// TODO: delete and update
|
|
||||||
|
|
||||||
export const merge = (
|
export const merge = (subscription: ISubscription | IServerSubscription, room?: IRoom | IServerRoom): ISubscription => {
|
||||||
subscription: ISubscription | IServerSubscriptionItem,
|
|
||||||
room?: ISubscription | IServerRoomItem | IRoom
|
|
||||||
): ISubscription => {
|
|
||||||
const serverVersion = reduxStore.getState().server.version as string;
|
const serverVersion = reduxStore.getState().server.version as string;
|
||||||
subscription = EJSON.fromJSONValue(subscription) as ISubscription;
|
const mergedSubscription: ISubscription = EJSON.fromJSONValue(subscription);
|
||||||
|
|
||||||
if (room) {
|
if (room) {
|
||||||
room = EJSON.fromJSONValue(room) as ISubscription;
|
room = EJSON.fromJSONValue(room);
|
||||||
if (room._updatedAt) {
|
if (room?._updatedAt) {
|
||||||
subscription.lastMessage = normalizeMessage(room.lastMessage);
|
mergedSubscription.lastMessage = normalizeMessage(room.lastMessage);
|
||||||
subscription.description = room.description;
|
mergedSubscription.description = room.description;
|
||||||
subscription.topic = room.topic;
|
mergedSubscription.topic = room.topic;
|
||||||
subscription.announcement = room.announcement;
|
mergedSubscription.announcement = room.announcement;
|
||||||
subscription.reactWhenReadOnly = room.reactWhenReadOnly;
|
mergedSubscription.reactWhenReadOnly = room.reactWhenReadOnly;
|
||||||
subscription.archived = room.archived || false;
|
mergedSubscription.archived = room.archived || false;
|
||||||
subscription.joinCodeRequired = room.joinCodeRequired;
|
mergedSubscription.joinCodeRequired = room.joinCodeRequired;
|
||||||
subscription.jitsiTimeout = room.jitsiTimeout;
|
mergedSubscription.jitsiTimeout = room.jitsiTimeout;
|
||||||
subscription.usernames = room.usernames;
|
mergedSubscription.usernames = room.usernames;
|
||||||
subscription.uids = room.uids;
|
mergedSubscription.uids = room.uids;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compareServerVersion(serverVersion, 'lowerThan', '3.7.0')) {
|
if (compareServerVersion(serverVersion, 'lowerThan', '3.7.0')) {
|
||||||
const updatedAt = room?._updatedAt ? new Date(room._updatedAt) : null;
|
const updatedAt = room?._updatedAt ? new Date(room._updatedAt) : null;
|
||||||
|
// @ts-ignore
|
||||||
const lastMessageTs = subscription?.lastMessage?.ts ? new Date(subscription.lastMessage.ts) : null;
|
const lastMessageTs = subscription?.lastMessage?.ts ? new Date(subscription.lastMessage.ts) : null;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
// If all parameters are null it will return zero, if only one is null it will return its timestamp only.
|
// If all parameters are null it will return zero, if only one is null it will return its timestamp only.
|
||||||
// "It works", but it's not the best solution. It does not accept "Date" as a parameter, but it works.
|
// "It works", but it's not the best solution. It does not accept "Date" as a parameter, but it works.
|
||||||
subscription.roomUpdatedAt = Math.max(updatedAt, lastMessageTs);
|
mergedSubscription.roomUpdatedAt = Math.max(updatedAt, lastMessageTs);
|
||||||
} else {
|
} else {
|
||||||
// https://github.com/RocketChat/Rocket.Chat/blob/develop/app/ui-sidenav/client/roomList.js#L180
|
// https://github.com/RocketChat/Rocket.Chat/blob/develop/app/ui-sidenav/client/roomList.js#L180
|
||||||
const lastRoomUpdate = room.lm || subscription.ts || subscription._updatedAt;
|
const lastRoomUpdate = room?.lm || subscription.ts || subscription._updatedAt;
|
||||||
// @ts-ignore Same as above scenario
|
// @ts-ignore Same as above scenario
|
||||||
subscription.roomUpdatedAt = subscription.lr
|
mergedSubscription.roomUpdatedAt = subscription.lr
|
||||||
? // @ts-ignore Same as above scenario
|
? // @ts-ignore Same as above scenario
|
||||||
Math.max(new Date(subscription.lr), new Date(lastRoomUpdate))
|
Math.max(new Date(subscription.lr), new Date(lastRoomUpdate))
|
||||||
: lastRoomUpdate;
|
: lastRoomUpdate;
|
||||||
}
|
}
|
||||||
subscription.ro = room.ro;
|
mergedSubscription.ro = room?.ro ?? false;
|
||||||
subscription.broadcast = room.broadcast;
|
mergedSubscription.broadcast = room?.broadcast;
|
||||||
subscription.encrypted = room.encrypted;
|
mergedSubscription.encrypted = room?.encrypted;
|
||||||
subscription.e2eKeyId = room.e2eKeyId;
|
mergedSubscription.e2eKeyId = room?.e2eKeyId;
|
||||||
subscription.avatarETag = room.avatarETag;
|
mergedSubscription.avatarETag = room?.avatarETag;
|
||||||
subscription.teamId = room.teamId;
|
mergedSubscription.teamId = room?.teamId;
|
||||||
subscription.teamMain = room.teamMain;
|
mergedSubscription.teamMain = room?.teamMain;
|
||||||
if (!subscription.roles || !subscription.roles.length) {
|
if (!mergedSubscription.roles || !mergedSubscription.roles.length) {
|
||||||
subscription.roles = [];
|
mergedSubscription.roles = [];
|
||||||
}
|
}
|
||||||
if (!subscription.ignored?.length) {
|
if (!mergedSubscription.ignored?.length) {
|
||||||
subscription.ignored = [];
|
mergedSubscription.ignored = [];
|
||||||
}
|
}
|
||||||
if (room.muted && room.muted.length) {
|
if (room?.muted?.length) {
|
||||||
subscription.muted = room.muted.filter(muted => !!muted);
|
mergedSubscription.muted = room.muted.filter(muted => !!muted);
|
||||||
} else {
|
} else {
|
||||||
subscription.muted = [];
|
mergedSubscription.muted = [];
|
||||||
}
|
}
|
||||||
if (room.v) {
|
if (room?.v) {
|
||||||
subscription.visitor = room.v;
|
mergedSubscription.visitor = room.v;
|
||||||
}
|
}
|
||||||
if (room.departmentId) {
|
if (room?.departmentId) {
|
||||||
subscription.departmentId = room.departmentId;
|
mergedSubscription.departmentId = room.departmentId;
|
||||||
}
|
}
|
||||||
if (room.servedBy) {
|
if (room?.servedBy) {
|
||||||
subscription.servedBy = room.servedBy;
|
mergedSubscription.servedBy = room.servedBy;
|
||||||
}
|
}
|
||||||
if (room.livechatData) {
|
if (room?.livechatData) {
|
||||||
subscription.livechatData = room.livechatData;
|
mergedSubscription.livechatData = room.livechatData;
|
||||||
}
|
}
|
||||||
if (room.tags) {
|
if (room?.tags) {
|
||||||
subscription.tags = room.tags;
|
mergedSubscription.tags = room.tags;
|
||||||
}
|
}
|
||||||
subscription.sysMes = room.sysMes;
|
mergedSubscription.sysMes = room?.sysMes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!subscription.name) {
|
if (!mergedSubscription.name) {
|
||||||
subscription.name = subscription.fname as string;
|
mergedSubscription.name = mergedSubscription.fname as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!subscription.autoTranslate) {
|
if (!mergedSubscription.autoTranslate) {
|
||||||
subscription.autoTranslate = false;
|
mergedSubscription.autoTranslate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
subscription.blocker = !!subscription.blocker;
|
mergedSubscription.blocker = !!mergedSubscription.blocker;
|
||||||
subscription.blocked = !!subscription.blocked;
|
mergedSubscription.blocked = !!mergedSubscription.blocked;
|
||||||
return subscription;
|
return mergedSubscription;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async (serverSubscriptions: IServerSubscription, serverRooms: IServerRoom): Promise<ISubscription[]> => {
|
export default async (
|
||||||
|
serverSubscriptions: {
|
||||||
|
update: IServerSubscription[];
|
||||||
|
remove: IServerSubscription[];
|
||||||
|
success: boolean;
|
||||||
|
},
|
||||||
|
serverRooms: {
|
||||||
|
update: IServerRoom[];
|
||||||
|
remove: IServerRoom[];
|
||||||
|
success: boolean;
|
||||||
|
}
|
||||||
|
): Promise<ISubscription[]> => {
|
||||||
const subscriptions = serverSubscriptions.update;
|
const subscriptions = serverSubscriptions.update;
|
||||||
const rooms = serverRooms.update;
|
const rooms = serverRooms.update;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import { E2E_MESSAGE_TYPE } from '../../encryption/constants';
|
||||||
import updateMessages from '../updateMessages';
|
import updateMessages from '../updateMessages';
|
||||||
import {
|
import {
|
||||||
IMessage,
|
IMessage,
|
||||||
|
IServerRoom,
|
||||||
IRoom,
|
IRoom,
|
||||||
ISubscription,
|
ISubscription,
|
||||||
TMessageModel,
|
TMessageModel,
|
||||||
|
@ -37,11 +38,11 @@ const removeListener = (listener: { stop: () => void }) => listener.stop();
|
||||||
|
|
||||||
let streamListener: Promise<any> | false;
|
let streamListener: Promise<any> | false;
|
||||||
let subServer: string;
|
let subServer: string;
|
||||||
let queue: { [key: string]: ISubscription } = {};
|
let queue: { [key: string]: ISubscription | IRoom } = {};
|
||||||
let subTimer: number | null | false = null;
|
let subTimer: number | null | false = null;
|
||||||
const WINDOW_TIME = 500;
|
const WINDOW_TIME = 500;
|
||||||
|
|
||||||
const createOrUpdateSubscription = async (subscription: ISubscription, room: IRoom | ISubscription) => {
|
const createOrUpdateSubscription = async (subscription: ISubscription, room: IServerRoom | IRoom) => {
|
||||||
try {
|
try {
|
||||||
const db = database.active;
|
const db = database.active;
|
||||||
const subCollection = db.get('subscriptions');
|
const subCollection = db.get('subscriptions');
|
||||||
|
@ -243,15 +244,15 @@ const debouncedUpdate = (subscription: ISubscription) => {
|
||||||
InteractionManager.runAfterInteractions(() => {
|
InteractionManager.runAfterInteractions(() => {
|
||||||
if (batch[key]) {
|
if (batch[key]) {
|
||||||
if (/SUB/.test(key)) {
|
if (/SUB/.test(key)) {
|
||||||
const sub = batch[key];
|
const sub = batch[key] as ISubscription;
|
||||||
const roomQueueId = getRoomQueueId(sub.rid);
|
const roomQueueId = getRoomQueueId(sub.rid);
|
||||||
const room = batch[roomQueueId];
|
const room = batch[roomQueueId] as IRoom;
|
||||||
delete batch[roomQueueId];
|
delete batch[roomQueueId];
|
||||||
createOrUpdateSubscription(sub, room);
|
createOrUpdateSubscription(sub, room);
|
||||||
} else {
|
} else {
|
||||||
const room = batch[key];
|
const room = batch[key] as IRoom;
|
||||||
const subQueueId = getSubQueueId(room._id);
|
const subQueueId = getSubQueueId(room._id);
|
||||||
const sub = batch[subQueueId];
|
const sub = batch[subQueueId] as ISubscription;
|
||||||
delete batch[subQueueId];
|
delete batch[subQueueId];
|
||||||
createOrUpdateSubscription(sub, room);
|
createOrUpdateSubscription(sub, room);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { forwardRoom, ITransferData } from '../actions/room';
|
||||||
import { themes } from '../constants/colors';
|
import { themes } from '../constants/colors';
|
||||||
import OrSeparator from '../containers/OrSeparator';
|
import OrSeparator from '../containers/OrSeparator';
|
||||||
import Input from '../containers/UIKit/MultiSelect/Input';
|
import Input from '../containers/UIKit/MultiSelect/Input';
|
||||||
import { IBaseScreen, IRoom } from '../definitions';
|
import { IBaseScreen, IServerRoom } from '../definitions';
|
||||||
import I18n from '../i18n';
|
import I18n from '../i18n';
|
||||||
import RocketChat from '../lib/rocketchat';
|
import RocketChat from '../lib/rocketchat';
|
||||||
import { ChatsStackParamList } from '../stacks/types';
|
import { ChatsStackParamList } from '../stacks/types';
|
||||||
|
@ -34,7 +34,7 @@ const ForwardLivechatView = ({ navigation, route, theme }: IBaseScreen<ChatsStac
|
||||||
const [departmentTotal, setDepartmentTotal] = useState(0);
|
const [departmentTotal, setDepartmentTotal] = useState(0);
|
||||||
const [users, setUsers] = useState<IOptionsField[]>([]);
|
const [users, setUsers] = useState<IOptionsField[]>([]);
|
||||||
const [userId, setUser] = useState();
|
const [userId, setUser] = useState();
|
||||||
const [room, setRoom] = useState<IRoom>({} as IRoom);
|
const [room, setRoom] = useState<IServerRoom>({} as IServerRoom);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const rid = route.params?.rid;
|
const rid = route.params?.rid;
|
||||||
|
@ -82,7 +82,7 @@ const ForwardLivechatView = ({ navigation, route, theme }: IBaseScreen<ChatsStac
|
||||||
try {
|
try {
|
||||||
const result = await RocketChat.getRoomInfo(rid);
|
const result = await RocketChat.getRoomInfo(rid);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
setRoom(result.room as IRoom);
|
setRoom(result.room as IServerRoom);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
|
@ -1051,7 +1051,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
||||||
const { room } = this.state;
|
const { room } = this.state;
|
||||||
if ('id' in room) {
|
if ('id' in room) {
|
||||||
const { jitsiTimeout } = room;
|
const { jitsiTimeout } = room;
|
||||||
if (jitsiTimeout && jitsiTimeout < Date.now()) {
|
if (jitsiTimeout && jitsiTimeout < new Date()) {
|
||||||
showErrorAlert(I18n.t('Call_already_ended'));
|
showErrorAlert(I18n.t('Call_already_ended'));
|
||||||
} else {
|
} else {
|
||||||
RocketChat.callJitsi(room);
|
RocketChat.callJitsi(room);
|
||||||
|
|
|
@ -27,12 +27,11 @@ import * as HeaderButton from '../../containers/HeaderButton';
|
||||||
import database from '../../lib/database';
|
import database from '../../lib/database';
|
||||||
import { sanitizeLikeString } from '../../lib/database/utils';
|
import { sanitizeLikeString } from '../../lib/database/utils';
|
||||||
import getThreadName from '../../lib/methods/getThreadName';
|
import getThreadName from '../../lib/methods/getThreadName';
|
||||||
import getRoomInfo from '../../lib/methods/getRoomInfo';
|
import getRoomInfo, { IRoomInfoResult } from '../../lib/methods/getRoomInfo';
|
||||||
import { isIOS } from '../../utils/deviceInfo';
|
import { isIOS } from '../../utils/deviceInfo';
|
||||||
import { compareServerVersion } from '../../lib/utils';
|
import { compareServerVersion } from '../../lib/utils';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import { InsideStackParamList, ChatsStackParamList } from '../../stacks/types';
|
import { InsideStackParamList, ChatsStackParamList } from '../../stacks/types';
|
||||||
import { IRoom } from '../../definitions';
|
|
||||||
import { IEmoji } from '../../definitions/IEmoji';
|
import { IEmoji } from '../../definitions/IEmoji';
|
||||||
|
|
||||||
const QUERY_SIZE = 50;
|
const QUERY_SIZE = 50;
|
||||||
|
@ -82,7 +81,7 @@ class SearchMessagesView extends React.Component<ISearchMessagesViewProps, ISear
|
||||||
|
|
||||||
private encrypted: boolean | undefined;
|
private encrypted: boolean | undefined;
|
||||||
|
|
||||||
private room: Pick<IRoom, 'rid' | 'name' | 'fname' | 't'> | null | undefined;
|
private room?: IRoomInfoResult;
|
||||||
|
|
||||||
static navigationOptions = ({ navigation, route }: INavigationOption) => {
|
static navigationOptions = ({ navigation, route }: INavigationOption) => {
|
||||||
const options: StackNavigationOptions = {
|
const options: StackNavigationOptions = {
|
||||||
|
@ -109,7 +108,7 @@ class SearchMessagesView extends React.Component<ISearchMessagesViewProps, ISear
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
this.room = await getRoomInfo(this.rid);
|
this.room = (await getRoomInfo(this.rid)) ?? undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps: ISearchMessagesViewProps, nextState: ISearchMessagesViewState) {
|
shouldComponentUpdate(nextProps: ISearchMessagesViewProps, nextState: ISearchMessagesViewState) {
|
||||||
|
|
Loading…
Reference in New Issue