Rocket.Chat.ReactNative/app/definitions/ISubscription.ts

177 lines
4.2 KiB
TypeScript
Raw Normal View History

import Model from '@nozbe/watermelondb/Model';
import Relation from '@nozbe/watermelondb/Relation';
import { ILastMessage, TMessageModel } from './IMessage';
import { IRocketChatRecord } from './IRocketChatRecord';
import { IOmnichannelSource, 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',
DIRECT = 'd',
CHANNEL = 'c',
OMNICHANNEL = 'l',
E2E = 'e2e', // FIXME: this is not a type of subscription
THREAD = 'thread' // FIXME: this is not a type of subscription
}
export interface IVisitor {
_id?: string;
token?: string;
status: 'online' | 'busy' | 'away' | 'offline';
username?: string;
lastMessageTs?: Date;
}
export enum ERoomTypes {
DIRECT = 'direct',
GROUP = 'group',
CHANNEL = 'channel'
}
type RelationModified<T extends Model> = { fetch(): Promise<T[]> } & Relation<T>;
export interface ISubscription {
_id: string;
id: string;
_updatedAt?: string;
v?: IVisitor;
f: boolean;
t: SubscriptionType; // TODO: we need to review this type later
ts: string | Date;
ls: Date;
name: string;
fname?: string;
sanitizedFname?: string;
rid: string; // the same as id
open: boolean;
alert: boolean;
roles?: string[];
unread: number;
lm: string;
lr: string;
userMentions: number;
groupMentions: number;
tunread: string[];
tunreadUser?: string[];
tunreadGroup?: string[];
roomUpdatedAt: Date | number;
ro: boolean;
lastOpen?: Date;
description?: string;
announcement?: string;
bannerClosed?: boolean;
topic?: string;
blocked?: boolean;
blocker?: boolean;
reactWhenReadOnly?: boolean;
archived: boolean;
joinCodeRequired?: boolean;
muted?: string[];
unmuted?: string[];
ignored?: string[];
broadcast?: boolean;
prid?: string;
draftMessage?: string | null;
lastThreadSync?: Date;
jitsiTimeout?: Date;
autoTranslate?: boolean;
autoTranslateLanguage?: string;
lastMessage?: ILastMessage | null; // TODO: we need to use IMessage here
hideUnreadStatus?: boolean;
sysMes?: string[] | boolean;
uids?: string[];
usernames?: string[];
visitor?: IVisitor;
departmentId?: string;
status?: string;
servedBy?: IServedBy;
livechatData?: any;
tags?: string[];
E2EKey?: string;
2023-01-12 13:32:33 +00:00
E2ESuggestedKey?: string;
encrypted?: boolean;
e2eKeyId?: string;
avatarETag?: string;
teamId?: string;
teamMain?: boolean;
unsubscribe: () => Promise<any>;
separator?: boolean;
onHold?: boolean;
source?: IOmnichannelSource;
hideMentionStatus?: boolean;
usersCount?: number;
// https://nozbe.github.io/WatermelonDB/Relation.html#relation-api
messages: RelationModified<TMessageModel>;
threads: RelationModified<TThreadModel>;
threadMessages: RelationModified<TThreadMessageModel>;
uploads: RelationModified<TUploadModel>;
feat: mobile troubleshoot notifications (#5330) * feat: troubleshoot notification (#5198) * navigation done * create the icon inside roomslistview, navigation to push troubleshot and layout push troubleshoot * custom header * fix the rooms list view header icon * layout done * update the pt-br i18n * tweak on colors * feat: create notification in room view (#5250) * button and simple navigation done, missing master detail * navigation * add withTheme and colors to rightuttons * fix e2e test * feat: add troubleshooting to notifications pages (#5276) * feat: add troubleshooting to notifications pages * fix e2e test * feat: device notification settings (#5277) * iOS go to device notification setting to change the configuration * go to notification settings with android * add notifee * add the reducer and action * saga request done * add the setInAlert action * tweak at name and add focus to dispatch the request * use the foreground inside pushTroubleShoot to request the notification and fix the icon color * add the request at roomslistview didmount * remove the notification modulo from android * add patch * minor tweak * feat: test push notification (#5329) * feat: test push notification * restApi and definition * push.info and change properly the troubleshootingNotification * use the finally at try/catch * minor tweak * alert and push.info just for 6.6 * fix the react-native.config * minor tweaks * minor tweak * push.test as rest api * change the name from inAlertNotification to highlightTroubleshooting * feat: push quota * refactor the percentage state * removed the push quota feature * minor tweaks * update the link to push notification * the notification icon in the room header will appear if notifications are disabled or highlight troubleshoot is true * remove push quota texts * updated some of the push quota texts * chore: rename highlightTroubleshooting * chore: better prop naming * wip * chore: fix function name * chore: fix colors * fix: copy * chore: 💅 * chore: use fork * chore: naming * chore: fix init * chore: naming * chore: naming * Comment CE code * Use put on troubleshooting saga * Add db column * fix: check notification payload * action: organized translations * fix: push init --------- Co-authored-by: GleidsonDaniel <gleidson10daniel@hotmail.com> Co-authored-by: Diego Mello <diegolmello@gmail.com> Co-authored-by: GleidsonDaniel <GleidsonDaniel@users.noreply.github.com>
2024-03-04 11:27:24 +00:00
disableNotifications?: boolean;
}
export type TSubscriptionModel = ISubscription &
Model & {
asPlain: () => ISubscription;
};
export type TSubscription = TSubscriptionModel | ISubscription;
// 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;
ts: Date;
name: string;
alert?: 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;
2023-01-12 13:32:33 +00:00
E2ESuggestedKey?: 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;
}