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:
@@ -0,0 +1,10 @@
|
||||
import { AirGappedRestriction } from '@rocket.chat/license';
|
||||
|
||||
import { applyAirGappedRestrictionsValidation } from '../../../server/lib/cloud/license/airGappedRestrictionsWrapper';
|
||||
|
||||
applyAirGappedRestrictionsValidation.patch(async <T>(_: any, fn: () => Promise<T>): Promise<T> => {
|
||||
if (AirGappedRestriction.restricted) {
|
||||
throw new Error('restricted-workspace');
|
||||
}
|
||||
return fn();
|
||||
});
|
||||
7
apps/meteor/ee/server/patches/closeBusinessHour.ts
Normal file
7
apps/meteor/ee/server/patches/closeBusinessHour.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { closeBusinessHour, closeBusinessHourByAgentIds } from '../../../server/lib/omnichannel/business-hour/closeBusinessHour';
|
||||
import { getAgentIdsToHandle } from '../lib/omnichannel/business-hour/Helper';
|
||||
|
||||
closeBusinessHour.patch(async (_next, businessHour) => {
|
||||
const agentIds = await getAgentIdsToHandle(businessHour);
|
||||
return closeBusinessHourByAgentIds(businessHour._id, agentIds);
|
||||
});
|
||||
21
apps/meteor/ee/server/patches/fetchContactHistory.ts
Normal file
21
apps/meteor/ee/server/patches/fetchContactHistory.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { License } from '@rocket.chat/license';
|
||||
import { LivechatRooms } from '@rocket.chat/models';
|
||||
|
||||
import { fetchContactHistory } from '../../../server/lib/omnichannel/contacts/getContactHistory';
|
||||
|
||||
fetchContactHistory.patch(
|
||||
async (next, params) => {
|
||||
const { contactId, options, extraParams } = params;
|
||||
|
||||
if (!extraParams?.source || typeof extraParams.source !== 'string') {
|
||||
return next(params);
|
||||
}
|
||||
|
||||
return LivechatRooms.findClosedRoomsByContactAndSourcePaginated({
|
||||
contactId,
|
||||
source: extraParams.source,
|
||||
options,
|
||||
});
|
||||
},
|
||||
() => License.hasModule('contact-id-verification'),
|
||||
);
|
||||
4
apps/meteor/ee/server/patches/getInstanceList.ts
Normal file
4
apps/meteor/ee/server/patches/getInstanceList.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { getInstanceList } from '../../../server/api/lib/getInstanceList';
|
||||
import { Instance } from '../sdk';
|
||||
|
||||
getInstanceList.patch(() => Instance.getInstances());
|
||||
6
apps/meteor/ee/server/patches/index.ts
Normal file
6
apps/meteor/ee/server/patches/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import './closeBusinessHour';
|
||||
import './getInstanceList';
|
||||
import './verifyContactChannel';
|
||||
import './mergeContacts';
|
||||
import './isAgentAvailableToTakeContactInquiry';
|
||||
import './airGappedRestrictionsWrapper';
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { ILivechatContact, ILivechatVisitor, IOmnichannelSource } from '@rocket.chat/core-typings';
|
||||
import { License } from '@rocket.chat/license';
|
||||
import { LivechatContacts } from '@rocket.chat/models';
|
||||
|
||||
import { isAgentAvailableToTakeContactInquiry } from '../../../server/lib/omnichannel/contacts/isAgentAvailableToTakeContactInquiry';
|
||||
import { isVerifiedChannelInSource } from '../../../server/lib/omnichannel/contacts/isVerifiedChannelInSource';
|
||||
import { settings } from '../../../server/settings';
|
||||
|
||||
// If the contact is unknown and the setting to block unknown contacts is on, we must not allow the agent to take this inquiry
|
||||
// if the contact is not verified in this channel and the block unverified contacts setting is on, we should not allow the inquiry to be taken
|
||||
// otherwise, the contact is allowed to be taken
|
||||
export const runIsAgentAvailableToTakeContactInquiry = async (
|
||||
_next: any,
|
||||
visitorId: ILivechatVisitor['_id'],
|
||||
source: IOmnichannelSource,
|
||||
contactId: ILivechatContact['_id'],
|
||||
): Promise<{ error: string; value: false } | { value: true }> => {
|
||||
const contact = await LivechatContacts.findOneEnabledById<Pick<ILivechatContact, '_id' | 'unknown' | 'channels'>>(contactId, {
|
||||
projection: {
|
||||
unknown: 1,
|
||||
channels: 1,
|
||||
},
|
||||
});
|
||||
|
||||
if (!contact) {
|
||||
return { value: false, error: 'error-invalid-contact' };
|
||||
}
|
||||
|
||||
if (contact.unknown && settings.get<boolean>('Livechat_Block_Unknown_Contacts')) {
|
||||
return { value: false, error: 'error-unknown-contact' };
|
||||
}
|
||||
|
||||
const isContactVerified = (contact.channels.filter((channel) => isVerifiedChannelInSource(channel, visitorId, source)) || []).length > 0;
|
||||
if (!isContactVerified && settings.get<boolean>('Livechat_Block_Unverified_Contacts')) {
|
||||
return { value: false, error: 'error-unverified-contact' };
|
||||
}
|
||||
|
||||
return { value: true };
|
||||
};
|
||||
|
||||
isAgentAvailableToTakeContactInquiry.patch(runIsAgentAvailableToTakeContactInquiry, () => License.hasModule('contact-id-verification'));
|
||||
63
apps/meteor/ee/server/patches/mergeContacts.ts
Normal file
63
apps/meteor/ee/server/patches/mergeContacts.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import type { ILivechatContact, ILivechatContactChannel, ILivechatContactVisitorAssociation } from '@rocket.chat/core-typings';
|
||||
import { License } from '@rocket.chat/license';
|
||||
import { LivechatContacts, LivechatRooms, Settings } from '@rocket.chat/models';
|
||||
import type { ClientSession } from 'mongodb';
|
||||
|
||||
import { isSameChannel } from '../../../app/livechat/lib/isSameChannel';
|
||||
import { notifyOnSettingChanged } from '../../../server/lib/notifyListener';
|
||||
import { ContactMerger } from '../../../server/lib/omnichannel/contacts/ContactMerger';
|
||||
import { mergeContacts } from '../../../server/lib/omnichannel/contacts/mergeContacts';
|
||||
import { contactLogger as logger } from '../lib/omnichannel/logger';
|
||||
|
||||
export const runMergeContacts = async (
|
||||
_next: any,
|
||||
contactId: string,
|
||||
visitor: ILivechatContactVisitorAssociation,
|
||||
session?: ClientSession,
|
||||
): Promise<ILivechatContact | null> => {
|
||||
const originalContact = await LivechatContacts.findOneEnabledById(contactId, { session });
|
||||
if (!originalContact) {
|
||||
throw new Error('error-invalid-contact');
|
||||
}
|
||||
|
||||
const channel = originalContact.channels.find((channel: ILivechatContactChannel) => isSameChannel(channel.visitor, visitor));
|
||||
if (!channel) {
|
||||
throw new Error('error-invalid-channel');
|
||||
}
|
||||
|
||||
logger.debug({ msg: 'Getting similar contacts', contactId });
|
||||
|
||||
const similarContacts: ILivechatContact[] = await LivechatContacts.findSimilarVerifiedContacts(channel, contactId, { session });
|
||||
|
||||
if (!similarContacts.length) {
|
||||
logger.debug({ msg: 'No similar contacts found', contactId });
|
||||
return originalContact;
|
||||
}
|
||||
|
||||
logger.debug({ msg: 'Found contacts to merge', contactId, count: similarContacts.length });
|
||||
for await (const similarContact of similarContacts) {
|
||||
const fields = ContactMerger.getAllFieldsFromContact(similarContact);
|
||||
await ContactMerger.mergeFieldsIntoContact({ fields, contact: originalContact, session });
|
||||
}
|
||||
|
||||
const similarContactIds = similarContacts.map((c) => c._id);
|
||||
const { deletedCount } = await LivechatContacts.deleteMany({ _id: { $in: similarContactIds } }, { session });
|
||||
|
||||
const value = await Settings.incrementValueById('Merged_Contacts_Count', similarContacts.length, { returnDocument: 'after' });
|
||||
if (value) {
|
||||
void notifyOnSettingChanged(value);
|
||||
}
|
||||
logger.info({
|
||||
msg: 'contacts have been deleted and merged with a contact',
|
||||
similarContactIds,
|
||||
deletedCount,
|
||||
originalContactId: originalContact._id,
|
||||
});
|
||||
|
||||
logger.debug({ msg: 'Updating rooms with new contact id', contactId });
|
||||
await LivechatRooms.updateMergedContactIds(similarContactIds, contactId, { session });
|
||||
|
||||
return LivechatContacts.findOneEnabledById(contactId, { session });
|
||||
};
|
||||
|
||||
mergeContacts.patch(runMergeContacts, () => License.hasModule('contact-id-verification'));
|
||||
106
apps/meteor/ee/server/patches/verifyContactChannel.ts
Normal file
106
apps/meteor/ee/server/patches/verifyContactChannel.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
import { LivechatInquiryStatus } from '@rocket.chat/core-typings';
|
||||
import type { ILivechatContact, IOmnichannelRoom } from '@rocket.chat/core-typings';
|
||||
import { License } from '@rocket.chat/license';
|
||||
import { LivechatContacts, LivechatInquiry, LivechatRooms } from '@rocket.chat/models';
|
||||
|
||||
import { client, shouldRetryTransaction } from '../../../server/database/utils';
|
||||
import { QueueManager } from '../../../server/lib/omnichannel/QueueManager';
|
||||
import { mergeContacts } from '../../../server/lib/omnichannel/contacts/mergeContacts';
|
||||
import { verifyContactChannel } from '../../../server/lib/omnichannel/contacts/verifyContactChannel';
|
||||
import { contactLogger as logger } from '../lib/omnichannel/logger';
|
||||
|
||||
type VerifyContactChannelParams = {
|
||||
contactId: string;
|
||||
field: string;
|
||||
value: string;
|
||||
visitorId: string;
|
||||
roomId: string;
|
||||
};
|
||||
|
||||
async function _verifyContactChannel(
|
||||
params: VerifyContactChannelParams,
|
||||
room: Pick<IOmnichannelRoom, '_id' | 'source'>,
|
||||
attempts = 2,
|
||||
): Promise<ILivechatContact | null> {
|
||||
const { contactId, field, value, visitorId, roomId } = params;
|
||||
|
||||
const session = client.startSession();
|
||||
try {
|
||||
session.startTransaction();
|
||||
logger.debug({ msg: 'Start verifying contact channel', contactId, visitorId, roomId });
|
||||
|
||||
const updater = LivechatContacts.getUpdater();
|
||||
LivechatContacts.setVerifiedUpdateQuery(true, updater);
|
||||
LivechatContacts.setFieldAndValueUpdateQuery(field, value.toLowerCase(), updater);
|
||||
await LivechatContacts.updateFromUpdaterByAssociation({ visitorId, source: room.source }, updater, { session });
|
||||
|
||||
await LivechatRooms.update({ _id: roomId }, { $set: { verified: true } }, { session });
|
||||
logger.debug({ msg: 'Merging contacts', contactId, visitorId, roomId });
|
||||
|
||||
const mergeContactsResult = await mergeContacts(contactId, { visitorId, source: room.source }, session);
|
||||
|
||||
await session.commitTransaction();
|
||||
|
||||
return mergeContactsResult;
|
||||
} catch (e) {
|
||||
await session.abortTransaction();
|
||||
if (shouldRetryTransaction(e) && attempts > 0) {
|
||||
logger.debug({ msg: 'Retrying to verify contact channel', contactId, visitorId, roomId });
|
||||
return _verifyContactChannel(params, room, attempts - 1);
|
||||
}
|
||||
|
||||
logger.error({ msg: 'Error verifying contact channel', contactId, visitorId, roomId, error: e });
|
||||
throw new Error('error-verifying-contact-channel');
|
||||
} finally {
|
||||
await session.endSession();
|
||||
}
|
||||
}
|
||||
|
||||
export const runVerifyContactChannel = async (
|
||||
_next: any,
|
||||
params: {
|
||||
contactId: string;
|
||||
field: string;
|
||||
value: string;
|
||||
visitorId: string;
|
||||
roomId: string;
|
||||
},
|
||||
): Promise<ILivechatContact | null> => {
|
||||
const { roomId, contactId, visitorId } = params;
|
||||
|
||||
const room = await LivechatRooms.findOneById(roomId);
|
||||
if (!room) {
|
||||
throw new Error('error-invalid-room');
|
||||
}
|
||||
|
||||
const result = await _verifyContactChannel(params, room);
|
||||
|
||||
logger.debug({ msg: 'Finding inquiry', roomId });
|
||||
|
||||
// Note: we are not using the session here since allowing the transactional flow to be used inside the
|
||||
// saveQueueInquiry function would require a lot of changes across the codebase, so if we fail here we
|
||||
// will not be able to rollback the transaction. That is not a big deal since the contact will be properly
|
||||
// merged and the inquiry will be saved in the queue (will need to be taken manually by an agent though).
|
||||
const inquiry = await LivechatInquiry.findOneByRoomId(roomId);
|
||||
if (!inquiry) {
|
||||
// Note: if this happens, something is really wrong with the queue, so we should throw an error to avoid
|
||||
// carrying on a weird state.
|
||||
throw new Error('error-invalid-inquiry');
|
||||
}
|
||||
|
||||
if (inquiry.status === LivechatInquiryStatus.VERIFYING) {
|
||||
logger.debug({ msg: 'Verifying inquiry', roomId });
|
||||
await QueueManager.verifyInquiry(inquiry, room);
|
||||
}
|
||||
|
||||
logger.debug({
|
||||
msg: 'Contact channel has been verified and merged successfully',
|
||||
contactId,
|
||||
visitorId,
|
||||
roomId,
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
verifyContactChannel.patch(runVerifyContactChannel, () => License.hasModule('contact-id-verification'));
|
||||
Reference in New Issue
Block a user