Stop reseting isListed and is featured after each sync (#20111)
isListed and isFeatured are manually updated by the admin, it should not be updated if the application already exists
This commit is contained in:
-12
@@ -6,7 +6,6 @@ import { MarketplaceService } from 'src/engine/core-modules/application/applicat
|
||||
import { buildRegistryCdnUrl } from 'src/engine/core-modules/application/application-marketplace/utils/build-registry-cdn-url.util';
|
||||
import { resolveManifestAssetUrls } from 'src/engine/core-modules/application/application-marketplace/utils/resolve-manifest-asset-urls.util';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
import { MARKETPLACE_CURATED_APPLICATIONS } from 'src/engine/core-modules/application/application-marketplace/constants/marketplace-curated-applications.constant';
|
||||
|
||||
@Injectable()
|
||||
export class MarketplaceCatalogSyncService {
|
||||
@@ -27,12 +26,6 @@ export class MarketplaceCatalogSyncService {
|
||||
private async syncRegistryApps(): Promise<void> {
|
||||
const packages = await this.marketplaceService.fetchAppsFromRegistry();
|
||||
|
||||
const curatedIdentifiers = new Set(
|
||||
MARKETPLACE_CURATED_APPLICATIONS.map(
|
||||
(entry) => entry.universalIdentifier,
|
||||
),
|
||||
);
|
||||
|
||||
for (const pkg of packages) {
|
||||
try {
|
||||
const fetchedManifest =
|
||||
@@ -49,8 +42,6 @@ export class MarketplaceCatalogSyncService {
|
||||
const universalIdentifier =
|
||||
fetchedManifest.application.universalIdentifier;
|
||||
|
||||
const isFeatured = curatedIdentifiers.has(universalIdentifier);
|
||||
|
||||
const aboutDescription =
|
||||
fetchedManifest.application.aboutDescription ??
|
||||
(await this.marketplaceService.fetchReadmeFromRegistryCdn(
|
||||
@@ -87,10 +78,7 @@ export class MarketplaceCatalogSyncService {
|
||||
sourceType: ApplicationRegistrationSourceType.NPM,
|
||||
sourcePackage: pkg.name,
|
||||
latestAvailableVersion: pkg.version ?? null,
|
||||
isListed: true,
|
||||
isFeatured,
|
||||
manifest: manifestWithResolvedUrls,
|
||||
ownerWorkspaceId: null,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error(
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ export class MarketplaceQueryService {
|
||||
name: app?.displayName ?? registration.name,
|
||||
description: app?.description ?? '',
|
||||
icon: app?.icon ?? 'IconApps',
|
||||
author: app?.author ?? 'Unknown',
|
||||
author: `${app?.author ?? 'Unknown'}`,
|
||||
category: app?.category ?? '',
|
||||
logo: app?.logoUrl ?? undefined,
|
||||
sourcePackage: registration.sourcePackage ?? undefined,
|
||||
|
||||
+13
-8
@@ -25,6 +25,8 @@ import { ApplicationEntity } from 'src/engine/core-modules/application/applicati
|
||||
import { validateRedirectUri } from 'src/engine/core-modules/auth/utils/validate-redirect-uri.util';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { ApplicationRegistrationVariableService } from 'src/engine/core-modules/application/application-registration-variable/application-registration-variable.service';
|
||||
import { MARKETPLACE_CURATED_APPLICATIONS } from 'src/engine/core-modules/application/application-marketplace/constants/marketplace-curated-applications.constant';
|
||||
|
||||
const BCRYPT_SALT_ROUNDS = 10;
|
||||
|
||||
@Injectable()
|
||||
@@ -269,10 +271,7 @@ export class ApplicationRegistrationService {
|
||||
| 'sourceType'
|
||||
| 'sourcePackage'
|
||||
| 'latestAvailableVersion'
|
||||
| 'isListed'
|
||||
| 'isFeatured'
|
||||
| 'manifest'
|
||||
| 'ownerWorkspaceId'
|
||||
>,
|
||||
): Promise<void> {
|
||||
const existing = await this.findOneByUniversalIdentifier(
|
||||
@@ -287,23 +286,29 @@ export class ApplicationRegistrationService {
|
||||
sourcePackage: params.sourcePackage,
|
||||
latestAvailableVersion: params.latestAvailableVersion,
|
||||
manifest: params.manifest,
|
||||
isListed: params.isListed,
|
||||
isFeatured: params.isFeatured,
|
||||
});
|
||||
} else {
|
||||
const curatedIdentifiers = new Set(
|
||||
MARKETPLACE_CURATED_APPLICATIONS.map(
|
||||
(entry) => entry.universalIdentifier,
|
||||
),
|
||||
);
|
||||
|
||||
const isFeatured = curatedIdentifiers.has(params.universalIdentifier);
|
||||
|
||||
const registration = this.applicationRegistrationRepository.create({
|
||||
universalIdentifier: params.universalIdentifier,
|
||||
name: params.name,
|
||||
sourceType: params.sourceType,
|
||||
sourcePackage: params.sourcePackage,
|
||||
latestAvailableVersion: params.latestAvailableVersion,
|
||||
isListed: params.isListed,
|
||||
isFeatured: params.isFeatured,
|
||||
isListed: true,
|
||||
isFeatured,
|
||||
manifest: params.manifest,
|
||||
oAuthClientId: v4(),
|
||||
oAuthRedirectUris: [],
|
||||
oAuthScopes: [],
|
||||
ownerWorkspaceId: params.ownerWorkspaceId,
|
||||
ownerWorkspaceId: null,
|
||||
});
|
||||
|
||||
await this.applicationRegistrationRepository.save(registration);
|
||||
|
||||
Reference in New Issue
Block a user