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:
29
apps/meteor/server/lib/search/model/ISearchResult.ts
Normal file
29
apps/meteor/server/lib/search/model/ISearchResult.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { IMessage, IRoom, IUser, RoomType } from '@rocket.chat/core-typings';
|
||||
|
||||
export type IRawSearchResult = {
|
||||
message?: { docs: IMessage[] };
|
||||
room?: { docs: IRoom[] };
|
||||
};
|
||||
|
||||
export type ISearchResult = {
|
||||
message?: {
|
||||
docs: (IMessage & {
|
||||
user: IUser['_id'];
|
||||
rid: IRoom['_id'];
|
||||
r?: {
|
||||
name: string | undefined;
|
||||
t: RoomType;
|
||||
};
|
||||
username?: string;
|
||||
valid?: boolean;
|
||||
})[];
|
||||
};
|
||||
room?: {
|
||||
docs: {
|
||||
_id: IRoom['_id'];
|
||||
valid?: boolean;
|
||||
t?: RoomType;
|
||||
name?: string;
|
||||
}[];
|
||||
};
|
||||
};
|
||||
117
apps/meteor/server/lib/search/model/SearchProvider.ts
Normal file
117
apps/meteor/server/lib/search/model/SearchProvider.ts
Normal file
@@ -0,0 +1,117 @@
|
||||
import type { IMessageSearchSuggestion, IRoom, IUser } from '@rocket.chat/core-typings';
|
||||
import type { TranslationKey } from '@rocket.chat/ui-contexts';
|
||||
|
||||
import type { IRawSearchResult } from './ISearchResult';
|
||||
import { Settings } from './Settings';
|
||||
import { SearchLogger } from '../logger/logger';
|
||||
|
||||
export abstract class SearchProvider<TPayload = any> {
|
||||
private _key: string;
|
||||
|
||||
protected _settings: Settings;
|
||||
|
||||
/**
|
||||
* Create search provider, key must match /^[A-Za-z0-9]+$/
|
||||
*/
|
||||
constructor(key: string) {
|
||||
if (!key.match(/^[A-Za-z0-9]+$/)) {
|
||||
throw new Error(`cannot instantiate provider: ${key} does not match key-pattern`);
|
||||
}
|
||||
|
||||
SearchLogger.info({
|
||||
msg: 'create search provider',
|
||||
providerKey: key,
|
||||
});
|
||||
|
||||
this._key = key;
|
||||
this._settings = new Settings(key);
|
||||
}
|
||||
|
||||
/* --- basic params ---*/
|
||||
get key() {
|
||||
return this._key;
|
||||
}
|
||||
|
||||
abstract get i18nLabel(): TranslationKey;
|
||||
|
||||
abstract get i18nDescription(): TranslationKey;
|
||||
|
||||
get iconName() {
|
||||
return 'magnifier';
|
||||
}
|
||||
|
||||
get settings() {
|
||||
return this._settings.list();
|
||||
}
|
||||
|
||||
get settingsAsMap() {
|
||||
return this._settings.map();
|
||||
}
|
||||
|
||||
/* --- templates ---*/
|
||||
get resultTemplate() {
|
||||
return 'DefaultSearchResultTemplate';
|
||||
}
|
||||
|
||||
get suggestionItemTemplate() {
|
||||
return 'DefaultSuggestionItemTemplate';
|
||||
}
|
||||
|
||||
/* --- search functions ---*/
|
||||
/**
|
||||
* Search using the current search provider and check if results are valid for the user. The search result has
|
||||
* the format {messages:{start:0,numFound:1,docs:[{...}]},users:{...},rooms:{...}}
|
||||
* @param text the search text
|
||||
* @param context the context (uid, rid)
|
||||
* @param payload custom payload (e.g. for paging)
|
||||
* @param callback is used to return result an can be called with (error,result)
|
||||
*/
|
||||
public abstract search(
|
||||
userId: string,
|
||||
text: string,
|
||||
context: { uid?: IUser['_id']; rid: IRoom['_id'] },
|
||||
payload?: TPayload,
|
||||
callback?: (error: Error | null, result: IRawSearchResult) => void,
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns an ordered list of suggestions. The result should have at least the form [{text:string}]
|
||||
* @param _text the search text
|
||||
* @param _context the context (uid, rid)
|
||||
* @param _payload custom payload (e.g. for paging)
|
||||
* @param callback is used to return result an can be called with (error,result)
|
||||
*/
|
||||
suggest(
|
||||
_text: string,
|
||||
_context: { uid?: IUser['_id']; rid: IRoom['_id'] },
|
||||
_payload: TPayload,
|
||||
callback?: (error: Error | null, result: IMessageSearchSuggestion[]) => void,
|
||||
) {
|
||||
callback?.(null, []);
|
||||
}
|
||||
|
||||
get supportsSuggestions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* --- triggers ---*/
|
||||
on(_name: string, _value: unknown) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* --- livecycle ---*/
|
||||
run(reason: any) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._settings.load();
|
||||
this.start(reason, resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
start(_reason: any, resolve: (value: unknown) => void, _reject: (reason?: any) => void) {
|
||||
resolve(undefined);
|
||||
}
|
||||
|
||||
stop(resolve: () => void) {
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
48
apps/meteor/server/lib/search/model/Setting.ts
Normal file
48
apps/meteor/server/lib/search/model/Setting.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import type { SettingValue } from '@rocket.chat/core-typings';
|
||||
|
||||
import { settings } from '../../../settings';
|
||||
|
||||
/**
|
||||
* Setting Object in order to manage settings loading for providers and admin ui display
|
||||
*/
|
||||
export class Setting {
|
||||
private readonly _basekey: string;
|
||||
|
||||
public readonly key: string;
|
||||
|
||||
public readonly type: string;
|
||||
|
||||
public readonly defaultValue: SettingValue;
|
||||
|
||||
public readonly options: Record<string, unknown>;
|
||||
|
||||
private _value: SettingValue;
|
||||
|
||||
constructor(basekey: string, key: string, type: string, defaultValue: SettingValue, options = {}) {
|
||||
this._basekey = basekey;
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.defaultValue = defaultValue;
|
||||
this.options = options;
|
||||
this._value = undefined;
|
||||
}
|
||||
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Id is generated based on baseKey and key
|
||||
*/
|
||||
get id() {
|
||||
return `Search.${this._basekey}.${this.key}`;
|
||||
}
|
||||
|
||||
load() {
|
||||
this._value = settings.get(this.id);
|
||||
|
||||
if (this._value === undefined) {
|
||||
this._value = this.defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
apps/meteor/server/lib/search/model/Settings.ts
Normal file
45
apps/meteor/server/lib/search/model/Settings.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { SettingValue } from '@rocket.chat/core-typings';
|
||||
|
||||
import { Setting } from './Setting';
|
||||
|
||||
/**
|
||||
* Settings Object allows to manage Setting Objects
|
||||
*/
|
||||
export class Settings {
|
||||
private settings: Record<string, Setting>;
|
||||
|
||||
constructor(public basekey: string) {
|
||||
this.settings = {};
|
||||
}
|
||||
|
||||
add(key: string, type: string, defaultValue: SettingValue, options: Record<string, unknown>) {
|
||||
this.settings[key] = new Setting(this.basekey, key, type, defaultValue, options);
|
||||
}
|
||||
|
||||
list() {
|
||||
return Object.keys(this.settings).map((key) => this.settings[key]);
|
||||
}
|
||||
|
||||
map() {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the value for key
|
||||
*/
|
||||
get<TValue>(key: string) {
|
||||
if (!this.settings[key]) {
|
||||
throw new Error('Setting is not set');
|
||||
}
|
||||
return this.settings[key].value as TValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* load currently stored values of all settings
|
||||
*/
|
||||
load() {
|
||||
Object.keys(this.settings).forEach((key) => {
|
||||
this.settings[key].load();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user