diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs index 0afe0b64a..a1ca8c570 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs @@ -227,7 +227,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes if (app == null) { - app = await GetAppCoreAsync(appCommand.AggregateId); + app = await GetAppCoreAsync(appCommand.AggregateId, true); } if (app != null) @@ -307,11 +307,11 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes return grainFactory.GetGrain(id); } - private async Task GetAppCoreAsync(DomainId id) + private async Task GetAppCoreAsync(DomainId id, bool allowArchived = false) { var app = (await grainFactory.GetGrain(id.ToString()).GetStateAsync()).Value; - if (app.Version <= EtagVersion.Empty || app.IsArchived) + if (app.Version <= EtagVersion.Empty || (app.IsArchived && !allowArchived)) { return null; } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Schemas/Indexes/SchemasIndex.cs b/backend/src/Squidex.Domain.Apps.Entities/Schemas/Indexes/SchemasIndex.cs index dfc100b51..f6c7b486b 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Schemas/Indexes/SchemasIndex.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Schemas/Indexes/SchemasIndex.cs @@ -159,7 +159,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes if (schema == null) { - schema = await GetSchemaCoreAsync(schemaCommand.AggregateId); + schema = await GetSchemaCoreAsync(schemaCommand.AggregateId, true); } if (schema != null) @@ -204,11 +204,11 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes return grainFactory.GetGrain(appId.ToString()); } - private async Task GetSchemaCoreAsync(DomainId id) + private async Task GetSchemaCoreAsync(DomainId id, bool allowDeleted = false) { var schema = (await grainFactory.GetGrain(id.ToString()).GetStateAsync()).Value; - if (schema.Version <= EtagVersion.Empty || schema.IsDeleted) + if (schema.Version <= EtagVersion.Empty || (schema.IsDeleted && !allowDeleted)) { return null; } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs index 8fd163590..08040b8ab 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs @@ -413,7 +413,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes [Fact] public async Task Should_remove_app_from_indexes_when_app_gets_archived() { - SetupApp(); + SetupApp(isArchived: true); var command = new ArchiveApp { AppId = appId }; diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs index 73f388c00..213358e4c 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Indexes/SchemasIndexTests.cs @@ -287,7 +287,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes [Fact] public async Task Should_remove_schema_from_index_when_deleted_and_exists() { - var (schema, _) = SetupSchema(); + var (schema, _) = SetupSchema(isDeleted: true); var command = new DeleteSchema { SchemaId = schemaId, AppId = appId };