mirror of
https://github.com/strapi/strapi.git
synced 2025-09-02 21:32:43 +00:00
Move busines logic to EE folder and override default CE functions
This commit is contained in:
parent
4a4ccac025
commit
124cc09a8d
@ -2,7 +2,7 @@ import auth from './auth';
|
|||||||
import passport from './passport';
|
import passport from './passport';
|
||||||
import role from './role';
|
import role from './role';
|
||||||
import user from './user';
|
import user from './user';
|
||||||
import metrics from './metrics';
|
import * as metrics from './metrics';
|
||||||
import seatEnforcement from './seat-enforcement';
|
import seatEnforcement from './seat-enforcement';
|
||||||
import workflows from './review-workflows/workflows';
|
import workflows from './review-workflows/workflows';
|
||||||
import stages from './review-workflows/stages';
|
import stages from './review-workflows/stages';
|
||||||
|
@ -1,11 +1,51 @@
|
|||||||
|
import { assign } from 'lodash/fp';
|
||||||
|
import type { Strapi } from '@strapi/types';
|
||||||
|
import EE from '@strapi/strapi/dist/utils/ee';
|
||||||
|
import { getService } from '../utils';
|
||||||
|
|
||||||
const getSSOProvidersList = async () => {
|
const getSSOProvidersList = async () => {
|
||||||
const { providerRegistry } = strapi.admin.services.passport;
|
const { providerRegistry } = strapi.admin.services.passport;
|
||||||
|
|
||||||
return providerRegistry.getAll().map(({ uid }) => uid);
|
return providerRegistry.getAll().map(({ uid }: { uid: string }) => uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
const sendUpdateProjectInformation = async () => {
|
||||||
getSSOProvidersList,
|
let groupProperties = {};
|
||||||
|
|
||||||
|
const numberOfActiveAdminUsers = await getService('user').count({ isActive: true });
|
||||||
|
const numberOfAdminUsers = await getService('user').count();
|
||||||
|
|
||||||
|
if (EE.features.isEnabled('sso')) {
|
||||||
|
const SSOProviders = await getSSOProvidersList();
|
||||||
|
|
||||||
|
groupProperties = assign(groupProperties, { SSOProviders, isSSOConfigured: SSOProviders.length !== 0 });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EE.features.isEnabled('cms-content-releases')) {
|
||||||
|
const numberOfContentReleases = await strapi.entityService.count('plugin::content-releases.release');
|
||||||
|
const numberOfPublishedContentReleases = await strapi.entityService.count('plugin::content-releases.release', {
|
||||||
|
filters: { $not: { releasedAt: null } }
|
||||||
|
});
|
||||||
|
|
||||||
|
groupProperties = assign(groupProperties, { numberOfContentReleases, numberOfPublishedContentReleases });
|
||||||
|
}
|
||||||
|
|
||||||
|
groupProperties = assign(groupProperties, { numberOfActiveAdminUsers, numberOfAdminUsers });
|
||||||
|
|
||||||
|
strapi.telemetry.send('didUpdateProjectInformation', {
|
||||||
|
groupProperties
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const startCron = (strapi: Strapi) => {
|
||||||
|
strapi.cron.add({
|
||||||
|
'0 0 0 * * *': () => sendUpdateProjectInformation(),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
startCron,
|
||||||
|
getSSOProvidersList,
|
||||||
|
sendUpdateProjectInformation,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
|||||||
import EE from '@strapi/strapi/dist/utils/ee';
|
|
||||||
import type { Strapi } from '@strapi/types';
|
import type { Strapi } from '@strapi/types';
|
||||||
import { assign } from 'lodash/fp';
|
import { assign } from 'lodash/fp';
|
||||||
import { getService } from '../utils';
|
import { getService } from '../utils';
|
||||||
import metrics from '../../../ee/server/src/services/metrics';
|
|
||||||
|
|
||||||
const sendDidInviteUser = async () => {
|
const sendDidInviteUser = async () => {
|
||||||
const numberOfUsers = await getService('user').count();
|
const numberOfUsers = await getService('user').count();
|
||||||
@ -27,21 +25,6 @@ const sendUpdateProjectInformation = async () => {
|
|||||||
|
|
||||||
const numberOfActiveAdminUsers = await getService('user').count({ isActive: true });
|
const numberOfActiveAdminUsers = await getService('user').count({ isActive: true });
|
||||||
const numberOfAdminUsers = await getService('user').count();
|
const numberOfAdminUsers = await getService('user').count();
|
||||||
|
|
||||||
if (EE.features.isEnabled('sso')) {
|
|
||||||
const SSOProviders = await metrics.getSSOProvidersList();
|
|
||||||
|
|
||||||
groupProperties = assign(groupProperties, { SSOProviders, isSSOConfigured: SSOProviders.length !== 0 });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EE.features.isEnabled('cms-content-releases')) {
|
|
||||||
const numberOfContentReleases = await strapi.entityService.count('plugin::content-releases.release');
|
|
||||||
const numberOfPublishedContentReleases = await strapi.entityService.count('plugin::content-releases.release', {
|
|
||||||
filters: { $not: { releasedAt: null } }
|
|
||||||
});
|
|
||||||
|
|
||||||
groupProperties = assign(groupProperties, { numberOfContentReleases, numberOfPublishedContentReleases });
|
|
||||||
}
|
|
||||||
|
|
||||||
groupProperties = assign(groupProperties, { numberOfActiveAdminUsers, numberOfAdminUsers });
|
groupProperties = assign(groupProperties, { numberOfActiveAdminUsers, numberOfAdminUsers });
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user