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

This commit is contained in:
upstream-mirror
2026-09-16 01:21:02 +05:00
commit 30810eecd7
10161 changed files with 987110 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
import fs from 'node:fs';
import type { IImport } from '@rocket.chat/core-typings';
import { parse } from 'csv-parse/lib/sync';
import { Importer, ProgressStep, ImporterWebsocket } from '..';
import { addParsedContacts } from './addParsedContacts';
import type { ConverterOptions } from '../classes/ImportDataConverter';
import type { ImporterProgress } from '../classes/ImporterProgress';
import type { ImporterInfo } from '../definitions/ImporterInfo';
export class ContactImporter extends Importer {
private csvParser: (csv: string) => string[][];
constructor(info: ImporterInfo, importRecord: IImport, converterOptions: ConverterOptions = {}) {
super(info, importRecord, converterOptions);
this.csvParser = parse;
}
override async prepareUsingLocalFile(fullFilePath: string): Promise<ImporterProgress> {
this.logger.debug('start preparing import operation');
await this.converter.clearImportData();
ImporterWebsocket.progressUpdated({ rate: 0 });
await super.updateProgress(ProgressStep.PREPARING_CONTACTS);
// Reading the whole file at once for compatibility with the code written for the other importers
// We can change this to a stream once we improve the rest of the importer classes
const fileContents = fs.readFileSync(fullFilePath, { encoding: 'utf8' });
if (!fileContents || typeof fileContents !== 'string') {
throw new Error('Failed to load file contents.');
}
const parsedContacts = this.csvParser(fileContents);
const contactsCount = await addParsedContacts.call(this.converter, parsedContacts);
if (contactsCount === 0) {
this.logger.error('No contacts found in the import file.');
await super.updateProgress(ProgressStep.ERROR);
} else {
await super.updateRecord({ 'count.contacts': contactsCount, 'count.total': contactsCount });
ImporterWebsocket.progressUpdated({ rate: 100 });
}
return super.getProgress();
}
}

View File

@@ -0,0 +1,39 @@
import { Random } from '@rocket.chat/random';
import type { ImportDataConverter } from '../classes/ImportDataConverter';
export async function addParsedContacts(this: ImportDataConverter, parsedContacts: string[][]): Promise<number> {
const columnNames = parsedContacts.shift();
let addedContacts = 0;
for (const parsedData of parsedContacts) {
const contactData = parsedData.reduce(
(acc, value, index) => {
const columnName = columnNames && index < columnNames.length ? columnNames[index] : `column${index}`;
return {
...acc,
[columnName]: value,
};
},
{} as Record<string, string>,
);
if (!contactData.emails && !contactData.phones && !contactData.name) {
continue;
}
const { emails = '', phones = '', name = '', manager: contactManager = undefined, id = Random.id(), ...customFields } = contactData;
await this.addContact({
importIds: [id],
emails: emails.split(';'),
phones: phones.split(';'),
name,
contactManager,
customFields,
});
addedContacts++;
}
return addedContacts;
}

View File

@@ -0,0 +1,12 @@
import { License } from '@rocket.chat/license';
import { Importers } from '..';
import { ContactImporter } from './ContactImporter';
License.onValidFeature('contact-id-verification', () => {
Importers.add({
key: 'omnichannel_contact',
name: 'omnichannel_contacts_importer',
importer: ContactImporter,
});
});