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:
124
apps/meteor/server/lib/cloud/saveRegistrationData.ts
Normal file
124
apps/meteor/server/lib/cloud/saveRegistrationData.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
import { applyLicense } from '@rocket.chat/license';
|
||||
import { Settings } from '@rocket.chat/models';
|
||||
|
||||
import { settings } from '../../settings';
|
||||
import { syncCloudData } from './syncWorkspace/syncCloudData';
|
||||
import { updateAuditedBySystem } from '../../settings/lib/auditedSettingUpdates';
|
||||
import { notifyOnSettingChangedById } from '../notifyListener';
|
||||
|
||||
type SaveRegistrationDataDTO = {
|
||||
workspaceId: string;
|
||||
client_name: string;
|
||||
client_id: string;
|
||||
client_secret: string;
|
||||
client_secret_expires_at: number;
|
||||
publicKey: string;
|
||||
registration_client_uri: string;
|
||||
};
|
||||
|
||||
type ManualSaveRegistrationDataDTO = SaveRegistrationDataDTO & { licenseData: { license: string } };
|
||||
|
||||
export async function saveRegistrationData({
|
||||
workspaceId,
|
||||
client_name,
|
||||
client_id,
|
||||
client_secret,
|
||||
client_secret_expires_at,
|
||||
publicKey,
|
||||
registration_client_uri,
|
||||
}: SaveRegistrationDataDTO) {
|
||||
await saveRegistrationDataBase({
|
||||
workspaceId,
|
||||
client_name,
|
||||
client_id,
|
||||
client_secret,
|
||||
client_secret_expires_at,
|
||||
publicKey,
|
||||
registration_client_uri,
|
||||
});
|
||||
|
||||
await syncCloudData();
|
||||
}
|
||||
|
||||
async function saveRegistrationDataBase({
|
||||
workspaceId,
|
||||
client_name,
|
||||
client_id,
|
||||
client_secret,
|
||||
client_secret_expires_at,
|
||||
publicKey,
|
||||
registration_client_uri,
|
||||
}: SaveRegistrationDataDTO) {
|
||||
const settingsData = [
|
||||
{ _id: 'Register_Server', value: true },
|
||||
{ _id: 'Cloud_Workspace_Id', value: workspaceId },
|
||||
{ _id: 'Cloud_Workspace_Name', value: client_name },
|
||||
{ _id: 'Cloud_Workspace_Client_Id', value: client_id },
|
||||
{ _id: 'Cloud_Workspace_Client_Secret', value: client_secret },
|
||||
{ _id: 'Cloud_Workspace_Client_Secret_Expires_At', value: client_secret_expires_at },
|
||||
{ _id: 'Cloud_Workspace_PublicKey', value: publicKey },
|
||||
{ _id: 'Cloud_Workspace_Registration_Client_Uri', value: registration_client_uri },
|
||||
];
|
||||
|
||||
const promises = [
|
||||
...settingsData.map(({ _id, value }) =>
|
||||
updateAuditedBySystem({
|
||||
reason: 'saveRegistrationDataBase',
|
||||
})(Settings.updateValueById, _id, value),
|
||||
),
|
||||
];
|
||||
|
||||
(await Promise.all(promises)).forEach((value, index) => {
|
||||
if (value?.modifiedCount) {
|
||||
void notifyOnSettingChangedById(settingsData[index]._id);
|
||||
}
|
||||
});
|
||||
|
||||
// Question: Why is this taking so long that needs a timeout?
|
||||
// Answer: we use cache that requires a 'roundtrip' through the db and the application
|
||||
// we need to make sure that the cache is updated before we continue the procedures
|
||||
// we don't actually need to wait a whole second for this, but look this is just a retry mechanism it doesn't mean that actually takes all this time
|
||||
for (const retry of Array.from({ length: 10 })) {
|
||||
const isSettingsUpdated =
|
||||
settings.get('Register_Server') === true &&
|
||||
settings.get('Cloud_Workspace_Id') === workspaceId &&
|
||||
settings.get('Cloud_Workspace_Name') === client_name &&
|
||||
settings.get('Cloud_Workspace_Client_Id') === client_id &&
|
||||
settings.get('Cloud_Workspace_Client_Secret') === client_secret &&
|
||||
settings.get('Cloud_Workspace_Client_Secret_Expires_At') === client_secret_expires_at &&
|
||||
settings.get('Cloud_Workspace_PublicKey') === publicKey &&
|
||||
settings.get('Cloud_Workspace_Registration_Client_Uri') === registration_client_uri;
|
||||
|
||||
if (isSettingsUpdated) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (retry === 9) {
|
||||
throw new Error('Failed to save registration data');
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveRegistrationDataManual({
|
||||
workspaceId,
|
||||
client_name,
|
||||
client_id,
|
||||
client_secret,
|
||||
client_secret_expires_at,
|
||||
publicKey,
|
||||
registration_client_uri,
|
||||
licenseData,
|
||||
}: ManualSaveRegistrationDataDTO) {
|
||||
await saveRegistrationDataBase({
|
||||
workspaceId,
|
||||
client_name,
|
||||
client_id,
|
||||
client_secret,
|
||||
client_secret_expires_at,
|
||||
publicKey,
|
||||
registration_client_uri,
|
||||
});
|
||||
await applyLicense(licenseData.license, true);
|
||||
}
|
||||
Reference in New Issue
Block a user