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:
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user