From ab78098536fc488701d17822f51c663f3ee78531 Mon Sep 17 00:00:00 2001 From: Yash Rajpal <58601732+yash-rajpal@users.noreply.github.com> Date: Wed, 10 Jul 2024 06:42:00 +0530 Subject: [PATCH] add migration to update default button colors --- .../app/meteor-accounts-saml/server/lib/settings.ts | 10 +++++++--- apps/meteor/server/lib/oauth/updateOAuthServices.ts | 8 +++++--- apps/meteor/server/lib/refreshLoginServices.ts | 4 ++-- apps/meteor/server/startup/migrations/index.ts | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts b/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts index 5c16716720b04..6848e7490e1ad 100644 --- a/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts +++ b/apps/meteor/app/meteor-accounts-saml/server/lib/settings.ts @@ -106,7 +106,7 @@ const configureSamlService = function (samlConfigs: Record): IServi }; }; -export const loadSamlServiceProviders = async function (): Promise { +export const loadSamlServiceProviders = async function (shouldNotify = true): Promise { const serviceName = 'saml'; const services = settings.getByRegexp(/^(SAML_Custom_)[a-z]+$/i); @@ -121,7 +121,9 @@ export const loadSamlServiceProviders = async function (): Promise { const samlConfigs = getSamlConfigs(key); SAMLUtils.log(key); await LoginServiceConfiguration.createOrUpdateService(serviceName, samlConfigs); - void notifyOnLoginServiceConfigurationChangedByService(serviceName); + if (shouldNotify) { + void notifyOnLoginServiceConfigurationChangedByService(serviceName); + } return configureSamlService(samlConfigs); } @@ -135,7 +137,9 @@ export const loadSamlServiceProviders = async function (): Promise { return false; } - void notifyOnLoginServiceConfigurationChanged({ _id: service._id }, 'removed'); + if (shouldNotify) { + void notifyOnLoginServiceConfigurationChanged({ _id: service._id }, 'removed'); + } return false; }), diff --git a/apps/meteor/server/lib/oauth/updateOAuthServices.ts b/apps/meteor/server/lib/oauth/updateOAuthServices.ts index f1df9fbb7aa95..0ccfe6db2f9fb 100644 --- a/apps/meteor/server/lib/oauth/updateOAuthServices.ts +++ b/apps/meteor/server/lib/oauth/updateOAuthServices.ts @@ -15,7 +15,7 @@ import { import { settings } from '../../../app/settings/server/cached'; import { logger } from './logger'; -export async function updateOAuthServices(): Promise { +export async function updateOAuthServices(shouldNotify = true): Promise { const services = settings.getByRegexp(/^(Accounts_OAuth_|Accounts_OAuth_Custom-)[a-z0-9_]+$/i); const filteredServices = services.filter(([, value]) => typeof value === 'boolean'); for await (const [key, value] of filteredServices) { @@ -117,12 +117,14 @@ export async function updateOAuthServices(): Promise { } await LoginServiceConfiguration.createOrUpdateService(serviceKey, data); - void notifyOnLoginServiceConfigurationChangedByService(serviceKey); + if (shouldNotify) { + void notifyOnLoginServiceConfigurationChangedByService(serviceKey); + } } else { const service = await LoginServiceConfiguration.findOneByService(serviceName, { projection: { _id: 1 } }); if (service?._id) { const { deletedCount } = await LoginServiceConfiguration.removeService(service._id); - if (deletedCount > 0) { + if (deletedCount > 0 && shouldNotify) { void notifyOnLoginServiceConfigurationChanged({ _id: service._id }, 'removed'); } } diff --git a/apps/meteor/server/lib/refreshLoginServices.ts b/apps/meteor/server/lib/refreshLoginServices.ts index 41f3b647f05e8..9fcc2877702ac 100644 --- a/apps/meteor/server/lib/refreshLoginServices.ts +++ b/apps/meteor/server/lib/refreshLoginServices.ts @@ -4,8 +4,8 @@ import { loadSamlServiceProviders } from '../../app/meteor-accounts-saml/server/ import { updateCasServices } from './cas/updateCasService'; import { updateOAuthServices } from './oauth/updateOAuthServices'; -export async function refreshLoginServices(): Promise { +export async function refreshLoginServices(shouldNotify = true): Promise { await ServiceConfiguration.configurations.removeAsync({}); - await Promise.allSettled([updateOAuthServices(), loadSamlServiceProviders(), updateCasServices()]); + await Promise.allSettled([updateOAuthServices(shouldNotify), loadSamlServiceProviders(shouldNotify), updateCasServices()]); } diff --git a/apps/meteor/server/startup/migrations/index.ts b/apps/meteor/server/startup/migrations/index.ts index 2dadd2102360e..57517ba796b6f 100644 --- a/apps/meteor/server/startup/migrations/index.ts +++ b/apps/meteor/server/startup/migrations/index.ts @@ -43,5 +43,6 @@ import './v307'; import './v308'; import './v309'; import './v310'; +import './v311'; export * from './xrun';