Fix QA issues

This commit is contained in:
Rémi de Juvigny 2023-03-21 12:54:07 +01:00
parent b7f794a3f4
commit 498dc2fcbb
2 changed files with 18 additions and 14 deletions

View File

@ -132,7 +132,7 @@ const createAuditLogsService = (strapi) => {
async register() {
// Handle license being enabled
if (!state.eeEnableUnsubscribe) {
state.eeEnableUnsubscribe = strapi.eventHub.once('ee.enable', () => {
state.eeEnableUnsubscribe = strapi.eventHub.on('ee.enable', () => {
// Recreate the service to use the new license info
this.destroy();
this.register();
@ -141,7 +141,7 @@ const createAuditLogsService = (strapi) => {
// Handle license being updated
if (!state.eeUpdateUnsubscribe) {
state.eeUpdateUnsubscribe = strapi.eventHub.once('ee.update', () => {
state.eeUpdateUnsubscribe = strapi.eventHub.on('ee.update', () => {
// Recreate the service to use the new license info
this.destroy();
this.register();
@ -149,11 +149,16 @@ const createAuditLogsService = (strapi) => {
}
// Handle license being disabled
state.eeDisableUnsubscribe = strapi.eventHub.on('ee.disable', () => {
// Turn off service when the license gets disabled
// Only ee.enable and ee.update listeners remain active to recreate the service
this.destroy();
});
if (!state.eeDisableUnsubscribe) {
state.eeDisableUnsubscribe = strapi.eventHub.on('ee.disable', () => {
// Turn off service when the license gets disabled
// ee.enable and ee.update listeners remain active to recreate the service
this.destroy();
});
}
// Register the provider now because collections can't be added later at runtime
state.provider = await localProvider.register({ strapi });
// Check current state of license
if (!features.isEnabled('audit-logs')) {
@ -161,7 +166,6 @@ const createAuditLogsService = (strapi) => {
}
// Start saving events
state.provider = await localProvider.register({ strapi });
state.eventHubUnsubscribe = strapi.eventHub.subscribe(handleEvent.bind(this));
// Manage audit logs auto deletion

View File

@ -112,18 +112,18 @@ const onlineUpdate = async ({ strapi }) => {
try {
// Verify license and check if its info changed
const newLicenseInfo = verifyLicense(license);
const fieldsToCompare = ['licenseKey', 'features', 'plan'];
const licenseInfoChanged = !isEqual(
pick(fieldsToCompare, newLicenseInfo),
pick(fieldsToCompare, ee.licenseInfo)
);
const licenseInfoChanged =
!isEqual(newLicenseInfo.features, ee.licenseInfo.features) ||
newLicenseInfo.seats !== ee.licenseInfo.seats ||
newLicenseInfo.type !== ee.licenseInfo.type;
// Store the new license info
ee.licenseInfo = newLicenseInfo;
const wasEnabled = ee.enabled;
validateInfo();
// Notify EE features
if (licenseInfoChanged) {
if (licenseInfoChanged && wasEnabled) {
strapi.eventHub.emit('ee.update');
}
} catch (error) {