snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
186
apps/meteor/client/lib/chats/ChatAPI.ts
Normal file
186
apps/meteor/client/lib/chats/ChatAPI.ts
Normal file
@@ -0,0 +1,186 @@
|
||||
import type { IMessage, IRoom, ISubscription, IE2EEMessage, IUpload } from '@rocket.chat/core-typings';
|
||||
import type { IActionManager } from '@rocket.chat/ui-contexts';
|
||||
import type { RefObject } from 'react';
|
||||
|
||||
import type { Upload, EncryptedFile } from './Upload';
|
||||
import type { ReadStateManager } from './readStateManager';
|
||||
import type { FormattingButton } from '../messageBoxFormatting';
|
||||
|
||||
type Subscribable<T> = {
|
||||
get(): T;
|
||||
subscribe(callback: () => void): () => void;
|
||||
};
|
||||
|
||||
export type ComposerAPI = {
|
||||
release(): void;
|
||||
readonly text: string;
|
||||
readonly selection: { readonly start: number; readonly end: number };
|
||||
setText(
|
||||
text: string,
|
||||
options?: {
|
||||
selection?:
|
||||
| { readonly start?: number; readonly end?: number }
|
||||
| ((previous: { readonly start: number; readonly end: number }) => { readonly start?: number; readonly end?: number });
|
||||
},
|
||||
): void;
|
||||
wrapSelection(pattern: string): {
|
||||
selectionStart: number;
|
||||
selectionEnd: number;
|
||||
value: string;
|
||||
};
|
||||
insertText(text: string): void;
|
||||
insertNewLine(): void;
|
||||
clear(): void;
|
||||
focus(): void;
|
||||
blur(): void;
|
||||
|
||||
getCursorPosition(): number | undefined;
|
||||
|
||||
substring(start: number, end?: number): string;
|
||||
|
||||
replaceText(
|
||||
text: string,
|
||||
selection: {
|
||||
start: number;
|
||||
end: number;
|
||||
},
|
||||
): void;
|
||||
|
||||
setCursorToEnd(): void;
|
||||
setCursorToStart(): void;
|
||||
replyWith(text: string): Promise<void>;
|
||||
quoteMessage(message: IMessage): Promise<void>;
|
||||
dismissQuotedMessage(mid: IMessage['_id']): Promise<void>;
|
||||
dismissAllQuotedMessages(): Promise<void>;
|
||||
readonly quotedMessages: Subscribable<IMessage[]>;
|
||||
|
||||
setEditingMode(editing: boolean): void;
|
||||
readonly editing: Subscribable<boolean>;
|
||||
|
||||
setRecordingMode(recording: boolean): void;
|
||||
readonly recording: Subscribable<boolean>;
|
||||
|
||||
setRecordingVideo(recording: boolean): void;
|
||||
readonly recordingVideo: Subscribable<boolean>;
|
||||
|
||||
setIsMicrophoneDenied(isMicrophoneDenied: boolean): void;
|
||||
readonly isMicrophoneDenied: Subscribable<boolean>;
|
||||
|
||||
readonly formatters: Subscribable<FormattingButton[]>;
|
||||
|
||||
readonly composerRef: RefObject<HTMLElement | null>;
|
||||
|
||||
readonly uploads: UploadsAPI;
|
||||
};
|
||||
|
||||
export type DataAPI = {
|
||||
composeMessage(
|
||||
text: string,
|
||||
options: { sendToChannel?: boolean; quotedMessages: IMessage[]; originalMessage?: IMessage | null },
|
||||
): Promise<IMessage>;
|
||||
findMessageByID(mid: IMessage['_id']): Promise<IMessage | null>;
|
||||
getMessageByID(mid: IMessage['_id']): Promise<IMessage>;
|
||||
findLastMessage(): Promise<IMessage | undefined>;
|
||||
getLastMessage(): Promise<IMessage>;
|
||||
findPreviousOwnMessage(message?: IMessage): Promise<IMessage | undefined>;
|
||||
getPreviousOwnMessage(message: IMessage): Promise<IMessage>;
|
||||
findNextOwnMessage(message: IMessage): Promise<IMessage | undefined>;
|
||||
getNextOwnMessage(message: IMessage): Promise<IMessage>;
|
||||
pushEphemeralMessage(message: Omit<IMessage, 'rid' | 'tmid'>): Promise<void>;
|
||||
canUpdateMessage(message: IMessage): Promise<boolean>;
|
||||
updateMessage(message: Pick<IMessage, '_id' | 't'> & Partial<Omit<IMessage, '_id' | 't'>>, previewUrls?: string[]): Promise<void>;
|
||||
canDeleteMessage(message: IMessage): Promise<boolean>;
|
||||
deleteMessage(msgIdOrMsg: IMessage | IMessage['_id']): Promise<void>;
|
||||
getDraft(mid: IMessage['_id'] | undefined): Promise<string | undefined>;
|
||||
discardDraft(mid: IMessage['_id'] | undefined): Promise<void>;
|
||||
saveDraft(mid: IMessage['_id'] | undefined, text: string): Promise<void>;
|
||||
findRoom(): Promise<IRoom | undefined>;
|
||||
getRoom(): Promise<IRoom>;
|
||||
isSubscribedToRoom(): Promise<boolean>;
|
||||
joinRoom(): Promise<void>;
|
||||
findDiscussionByID(drid: IRoom['_id']): Promise<IRoom | undefined>;
|
||||
getDiscussionByID(drid: IRoom['_id']): Promise<IRoom>;
|
||||
findSubscription(): Promise<ISubscription | undefined>;
|
||||
getSubscription(): Promise<ISubscription>;
|
||||
findSubscriptionFromMessage(message: IMessage): Promise<ISubscription | undefined>;
|
||||
getSubscriptionFromMessage(message: IMessage): Promise<ISubscription>;
|
||||
};
|
||||
|
||||
export type EncryptedFileUploadContent = {
|
||||
rawFile: File;
|
||||
fileContent: { raw: Partial<IUpload>; encrypted?: IE2EEMessage['content'] };
|
||||
encryptedFile: EncryptedFile;
|
||||
};
|
||||
|
||||
export type UploadsAPI = {
|
||||
get(): readonly Upload[];
|
||||
subscribe(callback: () => void): () => void;
|
||||
wipeFailedOnes(): void;
|
||||
clear(): void;
|
||||
getProcessingUploads(): boolean;
|
||||
setProcessingUploads(processing: boolean): void;
|
||||
cancel(id: Upload['id']): void;
|
||||
removeUpload(id: Upload['id']): void;
|
||||
editUploadFileName: (id: Upload['id'], fileName: string) => void;
|
||||
editUploadAltText: (id: Upload['id'], altText: string) => void;
|
||||
send(file: File, encrypted?: never): Promise<void>;
|
||||
send(file: File, encrypted: EncryptedFileUploadContent): Promise<void>;
|
||||
};
|
||||
|
||||
export type ChatAPI = {
|
||||
readonly uid: string | undefined;
|
||||
readonly composer?: ComposerAPI;
|
||||
readonly setComposerAPI: (composer?: ComposerAPI) => void;
|
||||
readonly data: DataAPI;
|
||||
readonly readStateManager: ReadStateManager;
|
||||
readonly messageEditing: {
|
||||
toPreviousMessage(): Promise<void>;
|
||||
toNextMessage(): Promise<void>;
|
||||
editMessage(message: IMessage, options?: { cursorAtStart?: boolean }): Promise<void>;
|
||||
};
|
||||
|
||||
readonly currentEditingMessage: {
|
||||
setMID(mid: IMessage['_id']): void;
|
||||
getMID(): string | undefined;
|
||||
reset(): Promise<boolean>;
|
||||
stop(): Promise<void>;
|
||||
cancel(): Promise<void>;
|
||||
};
|
||||
|
||||
readonly emojiPicker: {
|
||||
open(el: Element, cb: (emoji: string) => void): void;
|
||||
close(): void;
|
||||
};
|
||||
|
||||
readonly action: {
|
||||
start(action: 'typing'): void;
|
||||
stop(action: 'typing' | 'recording' | 'uploading' | 'playing'): void;
|
||||
performContinuously(action: 'recording' | 'uploading' | 'playing'): void;
|
||||
};
|
||||
|
||||
ActionManager: IActionManager;
|
||||
|
||||
readonly flows: {
|
||||
readonly uploadFiles: ({ files, resetFileInput }: { files: readonly File[]; resetFileInput?: () => void }) => Promise<void>;
|
||||
readonly sendMessage: ({
|
||||
text,
|
||||
tshow,
|
||||
}: {
|
||||
text: string;
|
||||
tshow?: boolean;
|
||||
previewUrls?: string[];
|
||||
isSlashCommandAllowed?: boolean;
|
||||
tmid?: IMessage['tmid'];
|
||||
}) => Promise<boolean>;
|
||||
readonly processSlashCommand: (message: IMessage, userId: string | null) => Promise<boolean>;
|
||||
readonly processTooLongMessage: (message: IMessage) => Promise<boolean>;
|
||||
readonly processMessageEditing: (
|
||||
message: Pick<IMessage, '_id' | 't'> & Partial<Omit<IMessage, '_id' | 't'>>,
|
||||
previewUrls?: string[],
|
||||
) => Promise<boolean>;
|
||||
readonly processMessageUploads: (message: IMessage) => Promise<boolean>;
|
||||
readonly processSetReaction: (message: Pick<IMessage, 'msg'>) => Promise<boolean>;
|
||||
readonly requestMessageDeletion: (message: IMessage) => Promise<void>;
|
||||
readonly replyBroadcast: (message: IMessage) => Promise<void>;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user